No, until now i did not, but do i need a controller at all?
(In my opinion it should present values even i do not have a controller)
So now i even disabled the define of the controller IP in my sketch...
Posts made by HarrySteff
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
It is a gateway, here the serial output:
(nothing changes)⸮Hl⸮G⸮C⸮d⸮xpI⸮⸮0;255;3;0;9;338 MCO:BGN:INIT GW,CP=R-NGE---,VER=2.2.0-beta scandone f 0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 1 cnt connected with Fritzbox7390, channel 1 ip:192.168.0.137,mask:255.255.255.0,gw:192.168.0.1 .IP: 192.168.0.137 0;255;3;0;9;899 MCO:BGN:STP 0;255;3;0;9;948 MCO:REG:NOT NEEDED 0;255;3;0;9;1004 MCO:BGN:INIT OK,TSP=NA pm open,type:2 0
No local atached Sensor is presented?!?
I use a wemos d1 Mini...
Sensor is connected to Port D2
What digital-Input-Port Must i use?
I found some Pin mappings:
There it is Port 4 -
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
Okay i understood this, but how does my ESP8266 node (only wifi) knows where the gateway is`?
I think i must tell it somwhere?
I will try to remove defined
MY_CONTROLLER_IP_ADRESS & MY_USE_UDPposting serial output here...
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
@mfalkvidd Here is my Serial Output:
MCO:BGN:INIT GW,CP=R-NGE---,VER=2.2.0-beta scandone f 0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 0 (29) ..reconnect f -180, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 0 (29) ..reconnect f r0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 0 (29) ..reconnect f 0, .scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 0 (29) ..reconnect f -180, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 0 (29) ..reconnect f r0, scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 3 cnt connected with Fritzbox7390, channel 10 ip:192.168.0.137,mask:255.255.255.0,gw:192.168.0.1 .IP: 192.168.0.137 0;255;3;0;9;6400 MCO:BGN:STP 0;255;3;0;9;6473 MCO:REG:NOT NEEDED 0;255;3;0;9;6510 MCO:BGN:INIT OK,TSP=NA pm open,type:2 0
And nothing more happens...
I tried to give out some serial prints in "void presentation" section, but they did not appear...Strange...
For what is the MY_CONTROLLER_IP_ADRESS ? The IP i inserted here is the IP from my other/main "Mysensors-Gateway..."
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
Iam using Pimatic, but only for displaying Sensor values. I set my node ID's manually...
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
Okay i will, as soon as I'am back home... maybe monday! Thank you so far
-
RE: Waterpulse Sensor - ESP8266GW without Radio only as node
Mhhh, nobody has an idea?
It seems that the sensor did not "start" the "void presentation()" section of sketch... -
Waterpulse Sensor - ESP8266GW without Radio only as node
Dear experts,
i tried to setup my Wemos D1 mini Board as a node.
I used 2.2.0 Beta version of Mysensors API.
But it seems that only the gateway part is starting. Sensors are not presenting (serial monitor) nothing happens here after connection to WLAN is established...
Am i correct? These defines are for (W)LAN communication with my Gateway(192.168.0.136):#define MY_USE_UDP #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 136
Here my whole sketch:
// Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_ESP8266 #define MY_ESP8266_SSID "Fritzbox7390" #define MY_ESP8266_PASSWORD "xxx" // Enable UDP communication #define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS below // Set the hostname for the WiFi Client. This is the hostname // it will pass to the DHCP server if not static. #define MY_ESP8266_HOSTNAME "waterpulse-sensor" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,0,137 // If using static ip you can define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,0,1 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 136 // Enable inclusion mode //#define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway //#define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) //#define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button //#define MY_INCLUSION_MODE_BUTTON_PIN 3 // Set blinking period //#define MY_DEFAULT_LED_BLINK_PERIOD 300 // Flash leds on rx/tx/err // Led pins used if blinking feature is enabled above //#define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED #if defined(MY_USE_UDP) #include <WiFiUdp.h> #endif #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!) #define PULSE_FACTOR 1000 // Nummber of blinks per m3 of your meter (One rotation/liter) #define SLEEP_MODE false // flowvalue can only be reported when sleep mode is false. #define MAX_FLOW 40 // Max flow (l/min) value to report. This filters outliers. #define MY_NODE_ID 17 // Static Node ID #define CHILD_ID 1 // Id of the sensor child #include <ESP8266WiFi.h> #include <MySensors.h> unsigned long SEND_FREQUENCY = 30000; // Minimum time between send (in milliseconds). We don't want to spam the gateway. MyMessage flowMsg(CHILD_ID,V_FLOW); MyMessage volumeMsg(CHILD_ID,V_VOLUME); MyMessage lastCounterMsg(CHILD_ID,V_VAR1); double ppl = ((double)PULSE_FACTOR)/1000; // Pulses per liter volatile uint16_t pulseCount = 0; volatile uint16_t lastBlink = 0; volatile double flow = 0; bool pcReceived = false; unsigned long oldPulseCount = 0; unsigned long newBlink = 0; double oldflow = 0; double volume =0; double oldvolume =0; unsigned long lastSend =0; unsigned long lastPulse =0; void setup() { // initialize our digital pins internal pullup resistor so one pulse switches from high to low (less distortion) pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP); pulseCount = oldPulseCount = 0; // Fetch last known pulse count value from gw request(CHILD_ID, V_VAR1); lastSend = lastPulse = millis(); attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, FALLING); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Water Meter", "1.1"); // Register this device as Waterflow sensor present(CHILD_ID, S_WATER); } void loop() { unsigned long currentTime = millis(); // Only send values at a maximum frequency or woken up from sleep if (SLEEP_MODE || (currentTime - lastSend > SEND_FREQUENCY)) { lastSend=currentTime; if (!pcReceived) { //Last Pulsecount not yet received from controller, request it again request(CHILD_ID, V_VAR1); return; } if (!SLEEP_MODE && flow != oldflow) { oldflow = flow; Serial.print("l/min:"); Serial.println(flow); // Check that we dont get unresonable large flow value. // could hapen when long wraps or false interrupt triggered if (flow<((unsigned long)MAX_FLOW)) { send(flowMsg.set(flow, 2)); // Send flow value to gw } } // No Pulse count received in 2min if(currentTime - lastPulse > 120000) { flow = 0; } // Pulse count has changed if ((pulseCount != oldPulseCount)||(!SLEEP_MODE)) { oldPulseCount = pulseCount; Serial.print("pulsecount:"); Serial.println(pulseCount); send(lastCounterMsg.set(pulseCount)); // Send pulsecount value to gw in VAR1 double volume = ((double)pulseCount/((double)PULSE_FACTOR)); if ((volume != oldvolume)||(!SLEEP_MODE)) { oldvolume = volume; Serial.print("volume:"); Serial.println(volume, 3); send(volumeMsg.set(volume, 3)); // Send volume value to gw } } } if (SLEEP_MODE) { sleep(SEND_FREQUENCY); } } void receive(const MyMessage &message) { if (message.type==V_VAR1) { unsigned long gwPulseCount=message.getULong(); pulseCount += gwPulseCount; flow=oldflow=0; Serial.print("Received last pulse count from gw:"); Serial.println(pulseCount); pcReceived = true; } } void onPulse() { if (!SLEEP_MODE) { unsigned long newBlink = micros(); unsigned long interval = newBlink-lastBlink; if (interval!=0) { lastPulse = millis(); if (interval<500000L) { // Sometimes we get interrupt on RISING, 500000 = 0.5sek debounce ( max 120 l/min) return; } flow = (60000000.0 /interval) / ppl; } lastBlink = newBlink; } pulseCount++; }
Hope that somebody has an idea...
-
RE: SensebenderMicro with two additional DS18b20
Again, that was it! @tbowmo Thank you again so much! Everything is running smoothly
-
RE: SensebenderMicro with two additional DS18b20
@tbowmo WOW you are my hero... after a couple of test it seems working now... THANK YOU SO MUCH... I will try it now for a longer time THANKS again!
-
RE: SensebenderMicro with two additional DS18b20
I did some more tests, this is what i get in serial monitor:
15017 TSF:MSG:SEND,15-15-0-0,s=3,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:27.0 15026 TSF:MSG:SEND,15-15-0-0,s=4,c=1,t=1,pt=2,l=2,sg=0,ft=0,st=OK:45 15034 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 15039 MCO:SLP:TPD 15041 MCO:SLP:WUP=-1 15112 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 15117 MCO:SLP:TPD 15118 MCO:SLP:WUP=-1 TempDiff :0.01 HumDiff :0.00 15133 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 15138 MCO:SLP:TPD 15139 MCO:SLP:WUP=-1 T.DA: 26.19 15253 TSF:MSG:SEND,15-15-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:26.1 15259 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 15264 MCO:SLP:TPD 15266 MCO:SLP:WUP=-1 TempDiff :0.05 HumDiff :0.50 15281 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 15286 MCO:SLP:TPD 15288 MCO:SLP:WUP=-1 15358 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 15364 MCO:SLP:TPD 15366 MCO:SLP:WUP=-1 TempDiff :0.02 HumDiff :0.50 15380 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 15385 MCO:SLP:TPD 15386 MCO:SLP:WUP=-1 T.DA: 25.94 15444 TSF:MSG:SEND,15-15-0-0,s=0,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:25.9 15492 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 15497 MCO:SLP:TPD 15499 MCO:SLP:WUP=-1 TempDiff :0.11 HumDiff :0.50 15514 MCO:SLP:MS=750,SMS=0,I1=255,M1=255,I2=255,M2=255 15518 MCO:SLP:TPD 15520 MCO:SLP:WUP=-1 15591 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 15596 MCO:SLP:TPD 15598 MCO:SLP:WUP=-1 ⸮⸮⸮⸮⸮
After this i only get those little squares... and no more data are send... I have no more idea what to do...
-
RE: SensebenderMicro with two additional DS18b20
It is so strange... today i did some more tests... connected to serialmonitor... at the beginning all seems running correct but after a Little while i only see squares in my serial monitor output... BUT... again temperature and humidity from internal Sensors of sensebender are transmitted, only the two ds18b20 sensors did Not send anymore... i don't know what i can do now Hope anybody can help me.... thanks again
-
SensebenderMicro with two additional DS18b20
Dear experts, i have a problem with my sensebender micro with two additional DS18B20 Sensors. Since i upgraded the sketch from Version 1.5 to 2.1.1 the DS18b20 Sensors sends their temperature Values for about one hour or something like that and after this they did not send anymore. But the internal Temperature and Humidity Sensors (from Sensebender) does send the whole time... Can anybody helb me with this strange behavior? Here is my Sketch:
// Enable debug prints to serial monitor #define MY_DEBUG // Define a static node address, remove if you want auto address assignment #define MY_NODE_ID 15 // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 // Enable to support OTA for this node (needs DualOptiBoot boot-loader to fully work) //#define MY_OTA_FIRMWARE_FEATURE #include <SPI.h> #include <MySensors.h> #include <DallasTemperature.h> #include <OneWire.h> #include <Wire.h> #include <SI7021.h> #ifndef MY_OTA_FIRMWARE_FEATURE #include "drivers/SPIFlash/SPIFlash.cpp" #endif #include <EEPROM.h> #include <sha204_lib_return_codes.h> #include <sha204_library.h> #include <RunningAverage.h> #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No #define ONE_WIRE_BUS 7 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. float lastTemperatureDA[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); // Uncomment the line below, to transmit battery voltage as a normal sensor value //#define BATT_SENSOR 199 #define RELEASE "2.1.1" #define AVERAGES 2 // Child sensor ID's #define CHILD_ID_TEMP 3 #define CHILD_ID_HUM 4 // How many milli seconds between each measurement #define MEASURE_INTERVAL 60000 // How many milli seconds should we wait for OTA? #define OTA_WAIT_PERIOD 300 // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller #define FORCE_TRANSMIT_INTERVAL 30 // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes. // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with // TEMP_TRANSMIT_THRESHOLD for temperature threshold. #define HUMI_TRANSMIT_THRESHOLD 0.5 #define TEMP_TRANSMIT_THRESHOLD 0.5 // Pin definitions #define TEST_PIN A0 #define LED_PIN A2 #define ATSHA204_PIN 17 // A3 const int sha204Pin = ATSHA204_PIN; atsha204Class sha204(sha204Pin); SI7021 humiditySensor; SPIFlash flash(8, 0x1F65); // Sensor messages MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); #ifdef BATT_SENSOR MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE); #endif // Global settings int measureCount = 0; int sendBattery = 0; boolean isMetric = true; boolean highfreq = true; boolean transmission_occured = false; // Storage of old measurements float lastTemperatureSB = -100; int lastHumidity = -100; long lastBattery = -100; RunningAverage raHum(AVERAGES); void before() { // Startup up the OneWire library sensors.begin(); } /**************************************************** * * Setup code * ****************************************************/ void setup() { pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, LOW); Serial.begin(115200); Serial.print(F("Sensebender Micro FW ")); Serial.print(RELEASE); Serial.flush(); // First check if we should boot into test mode pinMode(TEST_PIN,INPUT); digitalWrite(TEST_PIN, HIGH); // Enable pullup if (!digitalRead(TEST_PIN)) testMode(); // Make sure that ATSHA204 is not floating pinMode(ATSHA204_PIN, INPUT); digitalWrite(ATSHA204_PIN, HIGH); digitalWrite(TEST_PIN,LOW); digitalWrite(LED_PIN, HIGH); humiditySensor.begin(); digitalWrite(LED_PIN, LOW); Serial.flush(); Serial.println(F(" - Online!")); isMetric = getControllerConfig().isMetric; Serial.print(F("isMetric: ")); Serial.println(isMetric); raHum.clear(); sendTempHumidityMeasurements(false); sendBattLevel(false); #ifdef MY_OTA_FIRMWARE_FEATURE Serial.println("OTA FW update enabled"); #endif // requestTemperatures() will not block current thread sensors.setWaitForConversion(false); } void presentation() { sendSketchInfo("Sensebender Micro", RELEASE); present(CHILD_ID_TEMP,S_TEMP); present(CHILD_ID_HUM,S_HUM); #ifdef BATT_SENSOR present(BATT_SENSOR, S_POWER); #endif // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { present(i, S_TEMP); } } /*********************************************** * * Main loop function * ***********************************************/ void loop() { measureCount ++; sendBattery ++; bool forceTransmit = false; transmission_occured = false; #ifndef MY_OTA_FIRMWARE_FEATURE if ((measureCount == 5) && highfreq) { clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power. highfreq = false; } #endif if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission forceTransmit = true; measureCount = 0; } sendTempHumidityMeasurements(forceTransmit); /* if (sendBattery > 60) { sendBattLevel(forceTransmit); // Not needed to send battery info that often sendBattery = 0; }*/ #ifdef MY_OTA_FIRMWARE_FEATURE if (transmission_occured) { wait(OTA_WAIT_PERIOD); } #endif // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // query conversion time and sleep until conversion completed int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution()); //NEW* int16_t conversionTime = millisToWaitForConversion(sensors.getResolution()); // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater) sleep(conversionTime); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperatureDA = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error #if COMPARE_TEMP == 1 if (lastTemperatureDA[i] != temperatureDA && temperatureDA != -127.00 && temperatureDA != 85.00) { #else if (temperatureDA != -127.00 && temperatureDA != 85.00) { #endif Serial.print("T.DA: ");Serial.println(sensors.getTempCByIndex(i)); // Send in the new temperature send(msg.setSensor(i).set(temperatureDA,1)); // Save new temperatures for next compare lastTemperatureDA[i]=temperatureDA; } } sleep(MEASURE_INTERVAL); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) * *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; si7021_env data = humiditySensor.getHumidityAndTemperature(); raHum.addValue(data.humidityPercent); float diffTemp = abs(lastTemperatureSB - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100.0); float diffHum = abs(lastHumidity - raHum.getAverage()); Serial.print(F("TempDiff :"));Serial.println(diffTemp); Serial.print(F("HumDiff :"));Serial.println(diffHum); if (isnan(diffHum)) tx = true; if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true; if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true; if (tx) { measureCount = 0; float temperatureSB = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0; int humidity = data.humidityPercent; Serial.print("T: ");Serial.println(temperatureSB); Serial.print("H: ");Serial.println(humidity); send(msgTemp.set(temperatureSB,1)); send(msgHum.set(humidity)); lastTemperatureSB = temperatureSB; lastHumidity = humidity; transmission_occured = true; if (sendBattery > 60) { sendBattLevel(true); // Not needed to send battery info that often sendBattery = 0; } } } /******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; #ifdef BATT_SENSOR float send_voltage = float(vcc)/1000.0f; send(msgBatt.set(send_voltage,3)); #endif // Calculate percentage vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 14.0; sendBatteryLevel(percent); transmission_occured = true; } } /******************************************* * * Internal battery ADC measuring * *******************************************/ long readVcc() { // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADcdMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA,ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high<<8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts } /**************************************************** * * Verify all peripherals, and signal via the LED if any problems. * ****************************************************/ void testMode() { uint8_t rx_buffer[SHA204_RSP_SIZE_MAX]; uint8_t ret_code; byte tests = 0; digitalWrite(LED_PIN, HIGH); // Turn on LED. Serial.println(F(" - TestMode")); Serial.println(F("Testing peripherals!")); Serial.flush(); Serial.print(F("-> SI7021 : ")); Serial.flush(); if (humiditySensor.begin()) { Serial.println(F("ok!")); tests ++; } else { Serial.println(F("failed!")); } Serial.flush(); Serial.print(F("-> Flash : ")); Serial.flush(); if (flash.initialize()) { Serial.println(F("ok!")); tests ++; } else { Serial.println(F("failed!")); } Serial.flush(); Serial.print(F("-> SHA204 : ")); ret_code = sha204.sha204c_wakeup(rx_buffer); Serial.flush(); if (ret_code != SHA204_SUCCESS) { Serial.print(F("Failed to wake device. Response: ")); Serial.println(ret_code, HEX); } Serial.flush(); if (ret_code == SHA204_SUCCESS) { ret_code = sha204.getSerialNumber(rx_buffer); if (ret_code != SHA204_SUCCESS) { Serial.print(F("Failed to obtain device serial number. Response: ")); Serial.println(ret_code, HEX); } else { Serial.print(F("Ok (serial : ")); for (int i=0; i<9; i++) { if (rx_buffer[i] < 0x10) { Serial.print('0'); // Because Serial.print does not 0-pad HEX } Serial.print(rx_buffer[i], HEX); } Serial.println(")"); tests ++; } } Serial.flush(); Serial.println(F("Test finished")); if (tests == 3) { Serial.println(F("Selftest ok!")); while (1) // Blink OK pattern! { digitalWrite(LED_PIN, HIGH); delay(200); digitalWrite(LED_PIN, LOW); delay(200); } } else { Serial.println(F("----> Selftest failed!")); while (1) // Blink FAILED pattern! Rappidly blinking.. { } } }
Thank you very much in advance.
Steff -
RE: Low power Distance Sensor - Hardware issues
Hello @qqlapraline
i want to build exactly this sensor like you do.
Can you help me with a wiring schema and a parts list?Thank you so much!
-
RE: Values which gateway reads are others then sensor sends???
Sorry @Anduril i don't know how to figure it out...
This is the corresponding thread in pimatic-forum:
https://forum.pimatic.org/topic/1853/mysensors-esp8266gateway-with-direct-rest-api-access-to-pimatic
but here is the sketch:/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * 1.2 HvdW - add REST-API functionality to push sensor data to pimatic * 1.1 HvdW - add mDNS, static ip * Version 1.0 - Henrik EKblad * Contribution by a-lurker and Anticimex, * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> * Contribution by Ivo Pullens (ESP8266 support) * * DESCRIPTION * The EthernetGateway sends data received from sensors to the WiFi link. * The gateway also accepts input on ethernet interface, which is then sent out to the radio network. * * VERA CONFIGURATION: * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003 * * LED purposes: * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. * The ESP8266 however requires different wiring: * nRF24L01+ ESP8266 * VCC VCC * CE GPIO4 * CSN/CS GPIO15 * SCK GPIO14 * MISO GPIO12 * MOSI GPIO13 * * Not all ESP8266 modules have all pins available on their external interface. * This code has been tested on an ESP-12 module. * The ESP8266 requires a certain pin configuration to download code, and another one to run code: * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch') * - Connect GPIO15 via 10K pulldown resistor to GND * - Connect CH_PD via 10K resistor to VCC * - Connect GPIO2 via 10K resistor to VCC * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch') * * Inclusion mode button: * - Connect GPIO5 via switch to GND ('inclusion switch') * * Hardware SHA204 signing is currently not supported! * * Make sure to fill in your ssid and WiFi password below for ssid & pass. */ #define NO_PORTB_PINCHANGES #include <SPI.h> #include <MySigningNone.h> #include <MySigningAtsha204Soft.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <EEPROM.h> #include <MyHwESP8266.h> #include <ESP8266WiFi.h> #include <MyParserSerial.h> #include <MySensor.h> #include <stdarg.h> #include "GatewayUtil.h" #include <ESP8266mDNS.h> #include <Base64.h> #define MY_DEBUG ///////////// WLAN settings //////////// const char *ssid = "Fritzbox7390"; // cannot be longer than 32 characters! const char *pass = "**************"; // String espName = "esp8266gateway"; // for avahi/bonjour name => gives in this example esp8266gateway.local ///////////// pimatic settings //////////// String pim_host = "192.168.0.120"; // your pimatic server const int pim_port = 8080; // your pimatic server port String pim_user = "admin"; // the user you use to read from & write to pimatic String pim_pass = "********"; // The password for that pim_user char authVal[40]; char authValEncoded[40]; ///////////// Configure a static ip address //////////// IPAddress ip(192,168,0,135); IPAddress gateway(192,168,0,1); IPAddress subnet(255,255,255,0); #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled #define INCLUSION_MODE_PIN 5 // Digital pin used for inclusion mode button #define RADIO_CE_PIN 4 // radio chip enable #define RADIO_SPI_SS_PIN 15 // radio SPI serial select #ifdef WITH_LEDS_BLINKING #define RADIO_ERROR_LED_PIN 7 // Error led pin #define RADIO_RX_LED_PIN 8 // Receive led pin #define RADIO_TX_LED_PIN 9 // the PCB, on board LED #endif // NRFRF24L01 radio driver (set low transmit power by default) MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW); //MyTransportRFM69 transport; // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) #ifdef MY_SIGNING_FEATURE MySigningNone signer; //MySigningAtsha204Soft signer; #endif // Hardware profile MyHwESP8266 hw; // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h MySensor gw(transport, hw #ifdef MY_SIGNING_FEATURE , signer #endif #ifdef WITH_LEDS_BLINKING , RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN #endif ); #define IP_PORT 5003 // The port you want to open #define MAX_SRV_CLIENTS 5 // how many clients should be able to telnet to this ESP8266 // a R/W server on the port static WiFiServer server(IP_PORT); static WiFiClient clients[MAX_SRV_CLIENTS]; static bool clientsConnected[MAX_SRV_CLIENTS]; static inputBuffer inputString[MAX_SRV_CLIENTS]; // Activate mDNS MDNSResponder mdns; String ClientIP; // send data WiFiClient client; #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) void output(const char *fmt, ... ) { char serialBuffer[MAX_SEND_LENGTH]; va_list args; va_start (args, fmt ); vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args); va_end (args); Serial.print(serialBuffer); for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (clients[i] && clients[i].connected()) { // Serial.print("Client "); Serial.print(i); Serial.println(" write"); clients[i].write((uint8_t*)serialBuffer, strlen(serialBuffer)); } } } void incomingMessageESP(const MyMessage &message) { String yourdata; char yourvariable[10]; // Pass along the message from sensors to serial line serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf)); Serial.print("Node-Sensor (yourvariable) ");Serial.print(message.sender);Serial.print("-");Serial.print(message.sensor);Serial.print("; Value ");Serial.println(message.getString(convBuf)); char host_char_array[pim_host.length()+1]; pim_host.toCharArray(host_char_array,pim_host.length()+1); if (!client.connect(host_char_array, pim_port)) { Serial.println("connection failed"); return; } // calculate Base64Login memset(authVal,0,40); (pim_user + String(":") + pim_pass).toCharArray(authVal, 40); memset(authValEncoded,0,40); base64_encode(authValEncoded, authVal, (pim_user + String(":") + pim_pass).length()); //Send Value received from node yourdata = "{\"type\": \"value\", \"valueOrExpression\": \"" + String(message.getString(convBuf)) + "\"}"; sprintf(yourvariable, "%d-%d",message.sender,message.sensor); client.print("PATCH /api/variables/"); client.print(yourvariable); client.print(" HTTP/1.1\r\n"); client.print("Authorization: Basic "); client.print(authValEncoded); client.print("\r\n"); client.print("Host: " + pim_host +"\r\n"); client.print("Content-Type:application/json\r\n"); client.print("Content-Length: "); client.print(yourdata.length()); client.print("\r\n\r\n"); client.print(yourdata); } void checkwifi(){ //check if connected to wifi - if not connect if (WiFi.status() != WL_CONNECTED){ (void)WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED){ delay(500); Serial.print("."); } // When connected set static ip WiFi.config(ip, gateway, subnet); Serial.println("Connected!"); Serial.print("IP: "); Serial.println(WiFi.localIP()); Serial.flush(); } } void setup() { // Setup console hw_init(); Serial.println(); Serial.println(); Serial.println("ESP8266 MySensors Gateway with pimatic interface"); Serial.print("Connecting to "); Serial.println(ssid); checkwifi(); // Start mDNS service if (!mdns.begin(espName.c_str(), WiFi.localIP())) { Serial.println("Error setting up MDNS responder!"); while(1) { delay(1000); } } setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output); // Initialize gateway at maximum PA level, channel 70 and callback for write operations //gw.begin(incomingMessage, 0, true, 0); gw.begin(incomingMessageESP, 0, true, 0); // start listening for clients server.begin(); server.setNoDelay(true); } void loop() { gw.process(); checkButtonTriggeredInclusion(); checkInclusionFinished(); // Go over list of clients and stop any that are no longer connected. // If the server has a new client connection it will be assigned to a free slot. bool allSlotsOccupied = true; for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (!clients[i].connected()) { if (clientsConnected[i]) { Serial.print("Client "); Serial.print(i); Serial.println(" disconnected"); clients[i].stop(); } //check if there are any new clients if (server.hasClient()) { clients[i] = server.available(); inputString[i].idx = 0; Serial.print("Client "); Serial.print(i); Serial.println(" connected"); output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY); } } bool connected = clients[i].connected(); clientsConnected[i] = connected; allSlotsOccupied &= connected; } if (allSlotsOccupied && server.hasClient()) { //no free/disconnected spot so reject Serial.println("No free slot available"); WiFiClient c = server.available(); c.stop(); } // Loop over clients connect and read available data for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { while(clients[i].connected() && clients[i].available()) { char inChar = clients[i].read(); if ( inputString[i].idx < MAX_RECEIVE_LENGTH - 1 ) { // if newline then command is complete if (inChar == '\n') { // a command was issued by the client // we will now try to send it to the actuator inputString[i].string[inputString[i].idx] = 0; // echo the string to the serial port Serial.print("Client "); Serial.print(i); Serial.print(": "); Serial.println(inputString[i].string); parseAndSend(gw, inputString[i].string); // clear the string: inputString[i].idx = 0; // Finished with this client's message. Next loop() we'll see if there's more to read. break; } else { // add it to the inputString: inputString[i].string[inputString[i].idx++] = inChar; } } else { // Incoming message too long. Throw away Serial.print("Client "); Serial.print(i); Serial.println(": Message too long"); inputString[i].idx = 0; // Finished with this client's message. Next loop() we'll see if there's more to read. break; } } } }
-
Values which gateway reads are others then sensor sends???
Hi,
i have a Problem. Using a sensebender micro as (Test)sensor and a ESP8266 as wifi gateway.
So my problem is the following:This is what the sensor sends out:
send: 15-15-0-0 s=1,c=1,t=0,pt=7,l=5,sg=0,st=ok:23.5 send: 15-15-0-0 s=2,c=1,t=1,pt=2,l=2,sg=0,st=ok:64 send: 15-15-0-0 s=3,c=1,t=0,pt=6,l=1,sg=0,st=ok:00 send: 15-15-0-0 s=4,c=1,t=0,pt=6,l=1,sg=0,st=ok:00
And this what my gateway gets:
0;0;3;0;9;read: 15-15-0 s=1,c=1,t=0,pt=7,l=5,sg=0:23.5 15;1;1;0;0;23.5 Node-Sensor (yourvariable) 15-1; Value 23.5 0;0;3;0;9;read: 15-15-0 s=2,c=1,t=1,pt=2,l=2,sg=0:1102839872 15;2;1;0;1;1090519104 Node-Sensor (yourvariable) 15-2; Value 1090519104 0;0;3;0;9;read: 15-15-0 s=3,c=1,t=0,pt=6,l=1,sg=0:00 15;3;1;0;0;00 Node-Sensor (yourvariable) 15-3; Value 00 0;0;3;0;9;read: 15-15-0 s=4,c=1,t=0,pt=6,l=1,sg=0:00 15;4;1;0;0;00 Node-Sensor (yourvariable) 15-4; Value 00
The Value for Humidity from S2 looks very strange... Can anybody help me what i do wrong?
(I tried it with example esp6266 sketch, too -> same strange values)Thank you!
-
Connecting a DS18b20 waterproof sensor to Sensebender micro
Dear all,
iam very new in mysensors forum, i want to start my first mysensors project. I already installed a WiFi gateway (ESP8266). Now i want to install my first sensor (Sensebender Micro) And i want to connect a waterproof DS18b20 (or maybe if possible two of them) Can somebody help me how to configure it? What do i have to add in "Default Sensor Sketch" of Sensebender Micro?/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Henrik Ekblad * * DESCRIPTION * Default sensor sketch for Sensebender Micro module * Act as a temperature / humidity sensor by default. * * If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals * * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below) * */ #include <MySensor.h> #include <Wire.h> #include <SI7021.h> #include <SPI.h> #include "utility/SPIFlash.h" #include <EEPROM.h> #include <sha204_lib_return_codes.h> #include <sha204_library.h> #include <RunningAverage.h> #include <avr/power.h> // Define a static node address, remove if you want auto address assignment //#define NODE_ADDRESS 3 // Uncomment the line below, to transmit battery voltage as a normal sensor value #define BATT_SENSOR 199 #define RELEASE "1.2" #define AVERAGES 2 // Child sensor ID's #define CHILD_ID_TEMP 1 #define CHILD_ID_HUM 2 // How many milli seconds between each measurement #define MEASURE_INTERVAL 60000 // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller #define FORCE_TRANSMIT_INTERVAL 30 // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes. // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with // TEMP_TRANSMIT_THRESHOLD for temperature threshold. #define HUMI_TRANSMIT_THRESHOLD 0.5 #define TEMP_TRANSMIT_THRESHOLD 0.5 // Pin definitions #define TEST_PIN A0 #define LED_PIN A2 #define ATSHA204_PIN 17 // A3 const int sha204Pin = ATSHA204_PIN; atsha204Class sha204(sha204Pin); SI7021 humiditySensor; SPIFlash flash(8, 0x1F65); MySensor gw; // Sensor messages MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); #ifdef BATT_SENSOR MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE); #endif // Global settings int measureCount = 0; int sendBattery = 0; boolean isMetric = true; boolean highfreq = true; // Storage of old measurements float lastTemperature = -100; int lastHumidity = -100; long lastBattery = -100; RunningAverage raHum(AVERAGES); /**************************************************** * * Setup code * ****************************************************/ void setup() { pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, LOW); Serial.begin(115200); Serial.print(F("Sensebender Micro FW ")); Serial.print(RELEASE); Serial.flush(); // First check if we should boot into test mode pinMode(TEST_PIN,INPUT); digitalWrite(TEST_PIN, HIGH); // Enable pullup if (!digitalRead(TEST_PIN)) testMode(); // Make sure that ATSHA204 is not floating pinMode(ATSHA204_PIN, INPUT); digitalWrite(ATSHA204_PIN, HIGH); digitalWrite(TEST_PIN,LOW); digitalWrite(LED_PIN, HIGH); #ifdef NODE_ADDRESS gw.begin(NULL, NODE_ADDRESS, false); #else gw.begin(NULL,AUTO,false); #endif humiditySensor.begin(); digitalWrite(LED_PIN, LOW); Serial.flush(); Serial.println(F(" - Online!")); gw.sendSketchInfo("Sensebender Micro", RELEASE); gw.present(CHILD_ID_TEMP,S_TEMP); gw.present(CHILD_ID_HUM,S_HUM); #ifdef BATT_SENSOR gw.present(BATT_SENSOR, S_POWER); #endif isMetric = gw.getConfig().isMetric; Serial.print(F("isMetric: ")); Serial.println(isMetric); raHum.clear(); sendTempHumidityMeasurements(false); sendBattLevel(false); } /*********************************************** * * Main loop function * ***********************************************/ void loop() { measureCount ++; sendBattery ++; bool forceTransmit = false; if ((measureCount == 5) && highfreq) { clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power. highfreq = false; } if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission forceTransmit = true; measureCount = 0; } gw.process(); sendTempHumidityMeasurements(forceTransmit); if (sendBattery > 60) { sendBattLevel(forceTransmit); // Not needed to send battery info that often sendBattery = 0; } gw.sleep(MEASURE_INTERVAL); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) * *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; si7021_env data = humiditySensor.getHumidityAndTemperature(); float oldAvgHum = raHum.getAverage(); raHum.addValue(data.humidityPercent); float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100); float diffHum = abs(oldAvgHum - raHum.getAverage()); Serial.print(F("TempDiff :"));Serial.println(diffTemp); Serial.print(F("HumDiff :"));Serial.println(diffHum); if (isnan(diffHum)) tx = true; if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true; if (diffHum >= HUMI_TRANSMIT_THRESHOLD) tx = true; if (tx) { measureCount = 0; float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0; int humidity = data.humidityPercent; Serial.print("T: ");Serial.println(temperature); Serial.print("H: ");Serial.println(humidity); gw.send(msgTemp.set(temperature,1)); gw.send(msgHum.set(humidity)); lastTemperature = temperature; lastHumidity = humidity; } } /******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; #ifdef BATT_SENSOR gw.send(msgBatt.set(vcc)); #endif // Calculate percentage vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 14.0; gw.sendBatteryLevel(percent); } } /******************************************* * * Internal battery ADC measuring * *******************************************/ long readVcc() { // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADcdMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA,ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high<<8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts } /**************************************************** * * Verify all peripherals, and signal via the LED if any problems. * ****************************************************/ void testMode() { uint8_t rx_buffer[SHA204_RSP_SIZE_MAX]; uint8_t ret_code; byte tests = 0; digitalWrite(LED_PIN, HIGH); // Turn on LED. Serial.println(F(" - TestMode")); Serial.println(F("Testing peripherals!")); Serial.flush(); Serial.print(F("-> SI7021 : ")); Serial.flush(); if (humiditySensor.begin()) { Serial.println(F("ok!")); tests ++; } else { Serial.println(F("failed!")); } Serial.flush(); Serial.print(F("-> Flash : ")); Serial.flush(); if (flash.initialize()) { Serial.println(F("ok!")); tests ++; } else { Serial.println(F("failed!")); } Serial.flush(); Serial.print(F("-> SHA204 : ")); ret_code = sha204.sha204c_wakeup(rx_buffer); Serial.flush(); if (ret_code != SHA204_SUCCESS) { Serial.print(F("Failed to wake device. Response: ")); Serial.println(ret_code, HEX); } Serial.flush(); if (ret_code == SHA204_SUCCESS) { ret_code = sha204.getSerialNumber(rx_buffer); if (ret_code != SHA204_SUCCESS) { Serial.print(F("Failed to obtain device serial number. Response: ")); Serial.println(ret_code, HEX); } else { Serial.print(F("Ok (serial : ")); for (int i=0; i<9; i++) { if (rx_buffer[i] < 0x10) { Serial.print('0'); // Because Serial.print does not 0-pad HEX } Serial.print(rx_buffer[i], HEX); } Serial.println(")"); tests ++; } } Serial.flush(); Serial.println(F("Test finished")); if (tests == 3) { Serial.println(F("Selftest ok!")); while (1) // Blink OK pattern! { digitalWrite(LED_PIN, HIGH); delay(200); digitalWrite(LED_PIN, LOW); delay(200); } } else { Serial.println(F("----> Selftest failed!")); while (1) // Blink FAILED pattern! Rappidly blinking.. { } } }
Thank you so much!
-
RE: Which are the *best* NRF24L01+ modules?
Thank you @AWI i will Order them to Test...
-
RE: Which are the *best* NRF24L01+ modules?
Good morning together, iam very new in mysensors forum, so this is my first post, and i have a question: a want to buy these NRF's can somebody tell me if they are okay?
https://www.amazon.de/Kuman-nRF24L01-Wireless-Transceiver-Compatible/dp/B01BVAAASY/ref=sr_1_fkmr0_1?ie=UTF8&qid=1464158231&sr=8-1-fkmr0&keywords=nordic+nrf24l01+10pcsThank you!