Open namsontr opened 7 years ago
Which example are you compiling?
Regards,
Le 22/03/2017 à 18:26, namsontr a écrit :
Hi Mr Pham Cong Duc, I used Arduino Pro Mini in its 3.3v, 8MHz which connected the HopeRF RFM 92W (Low-cost LoRa Iot Device: A step-by-step tutorial). But when i removed the power led and the board was put in <>, Wakes-up every 10 min, take a measure (temp) and send to GW 45 mA in sleep mode (expected 160uA in deep sleep mode) , 160 mA when active and sending. Do you have any ideal this situation? Thank you so much in advance for your valuable help.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CongducPham/LowCostLoRaGw/issues/86, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNEN-u6UJ9jTt28fZ3HzEmxkUDvwJVMks5roVm7gaJpZM4Mljzr.
C. Pham.
-- | ------------ Congduc PHAM - Professor -------------------------- | LIUPPA - Equipe T2I | U.P.P.A. Pau | http://liuppa.univ-pau.fr/ | http://www.univ-pau.fr | ||
---|---|---|---|---|---|---|---|
UPPA, LIUPPA laboratory, UFR Sciences et Techniques | |||||||
Avenue de l'Université - BP 1155 | |||||||
64013 PAU CEDEX, FRANCE | |||||||
phone: [33] (0) 5 59 40 75 94 | |||||||
fax: [33] (0) 5 59 40 76 54 | |||||||
Congduc.Pham@univ-pau.fr http://www.univ-pau.fr/~cpham | |||||||
---------------------------------------------------------------- |
I'm compiling Arduino_Lora_temp & Arduino_Lora_Simple_temp. Uncomment Paboost, powerlevel='x'. Thank you for your quickly answer.
is LOW_POWER uncommented?
Le 22/03/2017 à 21:55, namsontr a écrit :
I'm compiling Arduino_Lora_temp & Arduino_Lora_Simple_temp. Uncomment Paboost, powerlevel='x'. Thank you for your quickly answer.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CongducPham/LowCostLoRaGw/issues/86#issuecomment-288536630, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNEN0KvvReEFfpHp-gVO_qIWII-rm2_ks5roYq3gaJpZM4Mljzr.
C. Pham.
-- | ------------ Congduc PHAM - Professor -------------------------- | LIUPPA - Equipe T2I | U.P.P.A. Pau | http://liuppa.univ-pau.fr/ | http://www.univ-pau.fr | ||
---|---|---|---|---|---|---|---|
UPPA, LIUPPA laboratory, UFR Sciences et Techniques | |||||||
Avenue de l'Université - BP 1155 | |||||||
64013 PAU CEDEX, FRANCE | |||||||
phone: [33] (0) 5 59 40 75 94 | |||||||
fax: [33] (0) 5 59 40 76 54 | |||||||
Congduc.Pham@univ-pau.fr http://www.univ-pau.fr/~cpham | |||||||
---------------------------------------------------------------- |
Yes, uncomment Low_power. Successfully switch Lora module in sleep mode. This is your code:
/*
temperature sensor on analog 8 to test the LoRa gateway
Copyright (C) 2016 Congduc Pham, University of Pau, France
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the program. If not, see http://www.gnu.org/licenses/.
last update: Nov. 26th by C. Pham */
// Include the SX1272
// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // please uncomment only 1 choice //
//#define FCC_US_REGULATION //#define SENEGAL_REGULATION ///////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // please uncomment only 1 choice
//#define BAND900 //#define BAND433 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
// previous way for setting output power char powerLevel='x';
// previous way for setting output power // 'H' is actually 6dBm, so better to use the new way to set output power // char powerLevel='H';
const uint32_t DEFAULT_CHANNEL=CH_04_868;
const uint32_t DEFAULT_CHANNEL=CH_10_868;
const uint32_t DEFAULT_CHANNEL=CH_05_900;
const uint32_t DEFAULT_CHANNEL=CH_00_433;
// IMPORTANT /////////////////////////////////////////////////////////////////////////////////////////////////////////// // // uncomment if your radio is an HopeRF RFM92W, HopeRF RFM95W, Modtronix inAir9B, NiceRF1276 // or you known from the circuit diagram that output use the PABOOST line instead of the RFO line
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // COMMENT OR UNCOMMENT TO CHANGE FEATURES. // ONLY IF YOU KNOW WHAT YOU ARE DOING!!! OTHERWISE LEAVE AS IT IS
//#define NEW_DATA_FIELD
//#define WITH_ACK ///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // CHANGE HERE THE LORA MODE, NODE ADDRESS
//////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // CHANGE HERE THE THINGSPEAK FIELD BETWEEN 1 AND 4
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // CHANGE HERE THE READ PIN AND THE POWER PIN FOR THE TEMP. SENSOR
// use digital 8 to power the temperature sensor if needed
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // CHANGE HERE THE TIME IN MINUTES BETWEEN 2 READING & TRANSMISSION unsigned int idlePeriodInMin = 3; ///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////// // CHANGE HERE THE APPKEY, BUT IF GW CHECKS FOR APPKEY, MUST BE // IN THE APPKEY LIST MAINTAINED BY GW. uint8_t my_appKey[4]={5, 6, 7, 8}; ///////////////////////////////////////////////////////////////////
// we wrapped Serial.println to support the Arduino Zero or M0
// if you have a Pro Mini running at 5V, then change here // these boards work in 3.3V // Nexus board from Ideetron is a Mini // MK66FX1M0 is for Teensy36 // MK64FX512 is for Teensy35 // MK20DX256 is for Teensy31/32 // MKL26Z64 is for TeensyLC // SAMD21G18A is for Zero/M0 and FeatherM0 (Cortex-M0)
// also for all other boards, so change here if required.
// this is for the Teensy36, Teensy35, Teensy31/32 & TeensyLC // need v6 of Snooze library
SnoozeTimer timer; SnoozeBlock sleep_config(timer);
// you need the LowPower library from RocketScream // https://github.com/rocketscream/Low-Power
// use the RTC library
/ Create an rtc object / RTCZero rtc;
unsigned int nCycle = idlePeriodInMin*60/LOW_POWER_PERIOD;
double temp; unsigned long nextTransmissionTime=0L; char float_str[20]; uint8_t message[100]; int loraMode=LORAMODE;
struct sx1272config {
uint8_t flag1; uint8_t flag2; uint8_t seq; // can add other fields such as LoRa mode,... };
sx1272config my_sx1272config;
void setup() { int e;
// for the temperature sensor pinMode(TEMP_PIN_READ, INPUT); // and to power the temperature sensor pinMode(TEMP_PIN_POWER,OUTPUT);
rtc.begin();
digitalWrite(TEMP_PIN_POWER,HIGH);
delay(3000); // Open serial communications and wait for port to open:
SerialUSB.begin(38400);
Serial.begin(38400);
// Print a start message PRINT_CSTSTR("%s","Simple LoRa temperature sensor\n");
PRINT_CSTSTR("%s","Arduino Pro Mini detected\n");
PRINT_CSTSTR("%s","Arduino Nano detected\n");
PRINT_CSTSTR("%s","Arduino MINI/Nexus detected\n");
PRINT_CSTSTR("%s","Teensy31/32 detected\n");
PRINT_CSTSTR("%s","Arduino M0/Zero detected\n");
// Power ON the module sx1272.ON();
// get config from EEPROM EEPROM.get(0, my_sx1272config);
// found a valid config? if (my_sx1272config.flag1==0x12 && my_sx1272config.flag2==0x34) { PRINT_CSTSTR("%s","Get back previous sx1272 config\n");
// set sequence number for SX1272 library
sx1272._packetNumber=my_sx1272config.seq;
PRINT_CSTSTR("%s","Using packet sequence number of ");
PRINT_VALUE("%d", sx1272._packetNumber);
PRINTLN;
} else { // otherwise, write config and start over my_sx1272config.flag1=0x12; my_sx1272config.flag2=0x34; my_sx1272config.seq=sx1272._packetNumber; }
// Set transmission mode and print the result e = sx1272.setMode(loraMode); PRINT_CSTSTR("%s","Setting Mode: state "); PRINT_VALUE("%d", e); PRINTLN;
// enable carrier sense sx1272._enableCarrierSense=true;
// TODO: with low power, when setting the radio module in sleep mode // there seem to be some issue with RSSI reading sx1272._RSSIonSend=false;
// Select frequency channel e = sx1272.setChannel(DEFAULT_CHANNEL); PRINT_CSTSTR("%s","Setting Channel: state "); PRINT_VALUE("%d", e); PRINTLN;
// Select amplifier line; PABOOST or RFO
sx1272._needPABOOST=true; // previous way for setting output power powerLevel='x';
// previous way for setting output power // powerLevel='M';
// previous way for setting output power e = sx1272.setPower(powerLevel);
e = sx1272.setPowerDBM((uint8_t)MAX_DBM); PRINT_CSTSTR("%s","Setting Power: state "); PRINT_VALUE("%d", e); PRINTLN;
// Set the node address and print the result e = sx1272.setNodeAddress(node_addr); PRINT_CSTSTR("%s","Setting node addr: state "); PRINT_VALUE("%d", e); PRINTLN;
// Print a success message PRINT_CSTSTR("%s","SX1272 successfully configured\n");
delay(500); }
char ftoa(char a, double f, int precision) { long p[] = {0,10,100,1000,10000,100000,1000000,10000000,100000000};
char ret = a; long heiltal = (long)f; itoa(heiltal, a, 10); while (a != '\0') a++; a++ = '.'; long desimal = abs((long)((f - heiltal) p[precision])); itoa(desimal, a, 10); return ret; }
void loop(void) { long startSend; long endSend; uint8_t app_key_offset=0; int e;
// 600000+random(15,60)*1000 if (millis() > nextTransmissionTime) {
digitalWrite(TEMP_PIN_POWER,HIGH);
// security?
delay(200);
int value = analogRead(TEMP_PIN_READ);
digitalWrite(TEMP_PIN_POWER,LOW);
int value = analogRead(TEMP_PIN_READ);
// change here how the temperature should be computed depending on your sensor type
//
temp = value*TEMP_SCALE/1024.0;
PRINT_CSTSTR("%s","Reading ");
PRINT_VALUE("%d", value);
PRINTLN;
//temp = temp - 0.5;
temp = temp / 10.0;
PRINT_CSTSTR("%s","Temp is ");
PRINT_VALUE("%f", temp);
PRINTLN;
app_key_offset = sizeof(my_appKey);
// set the app key in the payload
memcpy(message,my_appKey,app_key_offset);
uint8_t r_size;
// then use app_key_offset to skip the app key
r_size=sprintf((char*)message+app_key_offset, "\\!#%d#TC/%.2f", field_index, temp);
r_size=sprintf((char*)message+app_key_offset, "\\!#%d#%.2f", field_index, temp);
ftoa(float_str,temp,2);
// this is for testing, uncomment if you just want to test, without a real temp sensor plugged
//strcpy(float_str, "21.55567");
r_size=sprintf((char*)message+app_key_offset,"\\!#%d#TC/%s",field_index,float_str);
// this is for testing, uncomment if you just want to test, without a real temp sensor plugged
//strcpy(float_str, "21.55567");
r_size=sprintf((char*)message+app_key_offset,"\\!#%d#%s",field_index,float_str);
r_size=sprintf((char*)message+app_key_offset, "\\!#%d#TC/%d", field_index, (int)temp);
r_size=sprintf((char*)message+app_key_offset, "\\!#%d#%d", field_index, (int)temp);
PRINT_CSTSTR("%s","Sending ");
PRINT_STR("%s",(char*)(message+app_key_offset));
PRINTLN;
PRINT_CSTSTR("%s","Real payload size is ");
PRINT_VALUE("%d", r_size);
PRINTLN;
int pl=r_size+app_key_offset;
sx1272.CarrierSense();
startSend=millis();
// indicate that we have an appkey
sx1272.setPacketType(PKT_TYPE_DATA | PKT_FLAG_DATA_WAPPKEY);
// just a simple data packet
sx1272.setPacketType(PKT_TYPE_DATA);
// Send message to the gateway and print the result
// with the app key if this feature is enabled
int n_retry=NB_RETRIES;
do {
e = sx1272.sendPacketTimeoutACK(DEFAULT_DEST_ADDR, message, pl);
if (e==3)
PRINT_CSTSTR("%s","No ACK");
n_retry--;
if (n_retry)
PRINT_CSTSTR("%s","Retry");
else
PRINT_CSTSTR("%s","Abort");
} while (e && n_retry);
e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, message, pl);
endSend=millis();
// save packet number for next packet in case of reboot
my_sx1272config.seq=sx1272._packetNumber;
EEPROM.put(0, my_sx1272config);
PRINT_CSTSTR("%s","LoRa pkt size ");
PRINT_VALUE("%d", pl);
PRINTLN;
PRINT_CSTSTR("%s","LoRa pkt seq ");
PRINT_VALUE("%d", sx1272.packet_sent.packnum);
PRINTLN;
PRINT_CSTSTR("%s","LoRa Sent in ");
PRINT_VALUE("%ld", endSend-startSend);
PRINTLN;
PRINT_CSTSTR("%s","LoRa Sent w/CAD in ");
PRINT_VALUE("%ld", endSend-sx1272._startDoCad);
PRINTLN;
PRINT_CSTSTR("%s","Packet sent, state ");
PRINT_VALUE("%d", e);
PRINTLN;
PRINT_CSTSTR("%s","Remaining ToA is ");
PRINT_VALUE("%d", sx1272.getRemainingToA());
PRINTLN;
PRINT_CSTSTR("%s","Switch to power saving mode\n");
e = sx1272.setSleepMode();
if (!e)
PRINT_CSTSTR("%s","Successfully switch LoRa module in sleep mode\n");
else
PRINT_CSTSTR("%s","Could not switch LoRa module in sleep mode\n");
FLUSHOUTPUT
delay(50);
// For Arduino M0 or Zero we use the built-in RTC
LowPower.standby();
rtc.setTime(17, 0, 0);
rtc.setDate(1, 1, 2000);
rtc.setAlarmTime(17, idlePeriodInMin, 0);
// for testing with 20s
//rtc.setAlarmTime(17, 0, 20);
rtc.enableAlarm(rtc.MATCH_HHMMSS);
//rtc.attachInterrupt(alarmMatch);
rtc.standbyMode();
PRINT_CSTSTR("%s","SAMD21G18A wakes up from standby\n");
FLUSHOUTPUT
nCycle = idlePeriodInMin*60/LOW_POWER_PERIOD + random(2,4);
// warning, setTimer accepts value from 1ms to 65535ms max
timer.setTimer(LOW_POWER_PERIOD*1000 + random(1,5)*1000);// milliseconds
nCycle = idlePeriodInMin*60/LOW_POWER_PERIOD;
for (int i=0; i<nCycle; i++) {
// ATmega328P, ATmega168
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
//LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF,
// SPI_OFF, USART0_OFF, TWI_OFF);
// ATmega2560
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
//LowPower.idle(SLEEP_8S, ADC_OFF, TIMER5_OFF, TIMER4_OFF, TIMER3_OFF,
// TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART3_OFF,
// USART2_OFF, USART1_OFF, USART0_OFF, TWI_OFF);
// Teensy31/32 & TeensyLC
Snooze.hibernate(sleep_config);
Snooze.deepSleep(sleep_config);
// use the delay function
delay(LOW_POWER_PERIOD*1000);
PRINT_CSTSTR("%s",".");
FLUSHOUTPUT;
delay(10);
}
delay(50);
PRINT_VALUE("%ld", nextTransmissionTime);
PRINTLN;
PRINT_CSTSTR("%s","Will send next value at\n");
// use a random part also to avoid collision
nextTransmissionTime=millis()+(unsigned long)idlePeriodInMin*60*1000+(unsigned long)random(15,60)*1000;
PRINT_VALUE("%ld", nextTransmissionTime);
PRINTLN;
}
delay(50); }
I'm so sorry Mr Duc because i connected wrong pin VCC of HopeRF RFM 92W. I fixed this situation.
Great to hear that the issue is fixed.
Regards.
Envoyé de mon iPhone
Le 4 avr. 2017 à 21:39, namsontr notifications@github.com a écrit :
I'm so sorry Mr Duc because i connected wrong pin VCC of HopeRF RFM 92W. I fixed this situation.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Hi, I have the same problem, in sleep mode the power consumption is 5 mA. I made my own board, based on Pro Mini (3v3 8MHz), I don't understand the PABOOST define and his relation with pin DIO0, I have the SX1278 module and I'm using it with the Arduino_Lora_Generic_DHT.
Check that there is no led active and that the voltage regulator is removed. See this tutorial: https://www.youtube.com/watch?v=2_VQpcCwdd8
Thanks, It is the LDO the problem, now I have 18 uA in sleep Mode.
Hi Mr Pham Cong Duc, I used Arduino Pro Mini in its 3.3v, 8MHz which connected the HopeRF RFM 92W (Low-cost LoRa Iot Device: A step-by-step tutorial). But when i removed the power led and the board was put in <>, Wakes-up every 10 min, take a measure (temp) and send to GW 45 mA in sleep mode (expected 160uA in deep sleep mode) , 160 mA when active and sending.
Do you have any ideal this situation?
Thank you so much in advance for your valuable help.