Skip to content

Hardware

Talk about fun sensor hardware, MCUs, PCBs and how to power your sensors here.
1.8k Topics 18.3k Posts
  • Is Ethernet shield for Nano usable in any way?

    2
    0 Votes
    2 Posts
    81 Views
    OldSurferDudeO
    @NeoX I use a Nano, Ethernet, LCD display, and GPS for an NTP server on my isolated network to provide the time for [suspect] cameras. #define VER 12.2 bool debug = false; // must be true to have debug statements go to serial /* NTP Time Server: Modified by Gregg Ferry using softwareserial instead of Serial1 using GY-GPS6MV2 This code is in the public domain. ver 12 time server gets time from Arduino clock instead of from gps */ #define enableEthernet false #define enableGPS true #define enableDisplay true #define minimizeSerialTraffic true #if enableEthernet // ethernet #include <SPI.h> // needed for Arduino versions later than 0018 #include <Ethernet.h> #include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008 // Time Server MAC address byte mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; // NTP Server public IP Address IPAddress ip(192, 168, 2, 130); // Time Server Port #define NTP_PORT 123 unsigned int localPort = 123; static const int NTP_PACKET_SIZE = 48; // buffers for receiving and sending data byte packetBuffer[NTP_PACKET_SIZE]; // An Ethernet UDP instance EthernetUDP Udp; int packetSize; // NTP since 1900/01/01 //#include <PGMWrap.h> //const uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 }; //const or compiler complains const uint8_t daysInMonth [] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; //const or compiler complains const unsigned long seventyYears = 2208988800UL; // to convert unix time to epoch #endif #if enableGPS // GPS #include <TinyGPS++.h> //GPS instance TinyGPSPlus tinyGPS; #include <NeoSWSerial.h> //#include <SoftwareSerial.h> #define rxPin 5 #define txPin 4 NeoSWSerial GPSSerial(rxPin, txPin); // CONNECT BT RX PIN TO ARDUINO txPin | CONNECT BT TX PIN TO ARDUINO rxPin char incharBefore=255; char inchar=255; #endif #if enableDisplay // Display #include "SSD1306Ascii.h" #include "SSD1306AsciiAvrI2c.h" #define I2C_ADDRESS 0x3C SSD1306AsciiAvrI2c oled; #endif bool TimeHasBeenSet = false; bool firstPass = true; //Time #include <Timezone.h> //#include "Time.h" TimeChangeRule myDST = {"PDT", Second, Sun, Mar, 2, -420}; // Daylight time = UTC - 7 hours TimeChangeRule mySTD = {"PST", First, Sun, Nov, 2, -480}; // Standard time = UTC - 8 hours Timezone myTZ(myDST, mySTD); TimeChangeRule *tcr; // pointer to the time change rule, use to get TZ abbrev time_t local; String timeString = "hh:mm:ss"; String dateString = "yyyy MMM dd"; const String localDaysOfWeek[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" }; const String localMonthsOfYear[] = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"}; uint8_t localDayOfWeek; uint8_t previousHour = 0; uint8_t previousMinute = 0; uint8_t previousSecond = 0; unsigned long timestamp1970; //-----------------------------------------------------------------------------------printTimes void printTimes(){ Serial.print(F("GPS ")); Serial.print(tinyGPS.date.year());Serial.print(F("/")); Serial.print(tinyGPS.date.month());Serial.print(F("/")); Serial.print(tinyGPS.date.day());Serial.print(F(" ")); Serial.print(tinyGPS.time.hour());Serial.print(F(":")); Serial.print(tinyGPS.time.minute());Serial.print(F(":")); Serial.println(tinyGPS.time.second()); Serial.print(F("UTC ")); Serial.print(year());Serial.print(F("/")); Serial.print(month());Serial.print(F("/")); Serial.print(day());Serial.print(F(" ")); Serial.print(hour());Serial.print(F(":")); Serial.print(minute());Serial.print(F(":")); Serial.println(second()); Serial.print(F("local ")); Serial.print(year(local));Serial.print(F("/")); Serial.print(month(local));Serial.print(F("/")); Serial.print(day(local));Serial.print(F(" ")); Serial.print(hour(local));Serial.print(F(":")); Serial.print(minute(local));Serial.print(F(":")); Serial.println(second(local)); Serial.print(F(" ")); Serial.print(dateString);Serial.print(F(" ")); Serial.println(timeString); } //-----------------------------------------------------------------------------------setTimeAndDateStrings void setTimeAndDateStrings(){ local = myTZ.toLocal(now(), &tcr); // two days ago -172800 char buf[32]; sprintf(buf, "%.2d:%.2d:%.2d",hour(local), minute(local), second(local)); timeString = String(buf); // char m[4]; // temporary storage for month string (DateStrings.cpp uses shared buffer) // strcpy(m, monthShortStr(month(local))); // sprintf(buf, "%.2d %s %d",day(local), m, year(local)); // dateString = String(buf); sprintf(buf, "%.2d ",day(local)); dateString = String(buf); dateString += localMonthsOfYear[month(local)-1]; sprintf(buf," %d",year(local)); dateString += String(buf); localDayOfWeek = weekday(local)-1; } #if enableGPS //-----------------------------------------------------------------------------------getgps static bool getgps() { // and update arduino time if (GPSSerial.available()==0) return false; // while (GPSSerial.available()) { incharBefore = inchar; inchar = GPSSerial.read(); tinyGPS.encode(inchar); if (!TimeHasBeenSet) Serial.print(inchar); // } if ((inchar != 10) || (incharBefore != 13)) return false; // make sure to full NMEA statement was received inchar = 0; incharBefore = 0; // NMEA statement received, reset terminators if(tinyGPS.time.isValid()){ /* * setTime( tinyGPS.time.hour(), tinyGPS.time.minute(), tinyGPS.time.second(), tinyGPS.date.day(), tinyGPS.date.month(), tinyGPS.date.year() ); */ int hh=tinyGPS.time.hour(); int mm=tinyGPS.time.minute(); int ss=tinyGPS.time.second(); int DD=tinyGPS.date.day(); int MM=tinyGPS.date.month(); int YY=tinyGPS.date.year(); setTime(hh,mm,ss,DD,MM,YY); local = myTZ.toLocal(now(), &tcr); //get the local time setTimeAndDateStrings(); if (!TimeHasBeenSet) printTimes(); TimeHasBeenSet = true; return true; } else { return false; } } #endif #if enableDisplay //-----------------------------------------------------------------------------------displayGPStimeSetTheTime void displayGPStimeSetTheTime(bool TimeSetByGPS){ oled.setCursor(0,0); // Start at top-left corner if (TimeSetByGPS) oled.print(F(" ")); else oled.print(F("!")); } //-----------------------------------------------------------------------------------displayAwaitingGPS void displayAwaitingGPS() { oled.clear(); oled.setCursor(0,0); // Start at top-left corner oled.println(F("NTP Server")); oled.println(F(" Awating")); oled.println(F(" GPS Lock ")); Serial.println(F(" Awating GPS Lock ")); } //-----------------------------------------------------------------------------------displayNewDay void displayNewDay(){ previousHour = hour(local); previousMinute= minute(local); previousSecond = second(local); oled.clear(); oled.setCursor(12,0); // center time string oled.print(timeString); uint8_t s = (10-localDaysOfWeek[localDayOfWeek].length())*6; oled.setCursor(s,3); oled.print(localDaysOfWeek[localDayOfWeek]); oled.setCursor(0,6); oled.print(dateString); } //-----------------------------------------------------------------------------------displayTime void displayTime(){ // digital clock display of the time if ((second(local)==0 && minute(local)==0 && hour(local)==0) || firstPass){ // new day firstPass = false; displayNewDay(); } else { if (hour(local) != previousHour){ previousHour = hour(local); oled.setCursor(12,0); oled.print(timeString); } else { if (minute(local) != previousMinute){ previousMinute= minute(local); oled.setCursor(48,0); oled.print(timeString.substring(3)); } else { if (second(local) != previousSecond){ previousSecond = second(local); oled.setCursor(84,0); oled.print(timeString.substring(6)); } } } } } // send to serial monitor #else void displayGPStimeSetTheTime(bool TimeSetByGPS){ } void displayAwaitingGPS() { Serial.println(F(" Awating GPS Lock ")); } void displayTime(){ #if !minimizeSerialTraffic Serial.println(); printTimes(); #endif } #endif //-----------------------------------------------------------------------------------setup #if enableEthernet void setupEthernet(){ // start the Ethernet and UDP: Ethernet.begin(mac,ip); Udp.begin(localPort); Serial.print(Ethernet.localIP()); Serial.print(F(" "));Serial.println(NTP_PORT); } #endif #if enableGPS void setupGPS(){ GPSSerial.begin(9600); // start GPS module UART // Disable everything but $GPRMC // Note the following sentences are for UBLOX NEO6MV2 GPS GPSSerial.write("$PUBX,40,GLL,0,0,0,0,0,0*5C\r\n"); GPSSerial.write("$PUBX,40,VTG,0,0,0,0,0,0*5E\r\n"); GPSSerial.write("$PUBX,40,GSV,0,0,0,0,0,0*59\r\n"); GPSSerial.write("$PUBX,40,GGA,0,0,0,0,0,0*5A\r\n"); GPSSerial.write("$PUBX,40,GSA,0,0,0,0,0,0*4E\r\n"); } #endif #if enableDisplay void setupDisplay(){ oled.begin(&Adafruit128x64, I2C_ADDRESS); oled.setFont(System5x7); oled.set2X(); } #endif void setup() { Serial.begin(115200); Serial.print("NTP Server with display version ");Serial.println(VER); #if enableDisplay setupDisplay(); #endif displayAwaitingGPS(); #if enableEthernet setupEthernet(); #endif #if enableGPS setupGPS(); #endif } //-----------------------------------------------------------------------------------loop void loop() { /* while (Serial.available()){ char inChar = Serial.read(); if (inChar == 'd' || inChar == 'D') { debug = !debug; if (debug) Serial.println(F("debug is ON"));else Serial.println(F("debug is off")); } } */ #if enableGPS if (getgps()){ if(TimeHasBeenSet) displayTime(); } #endif #if enableEthernet // if there's data available, read a packet packetSize = Udp.parsePacket(); if(packetSize) processNTP(); #endif } #if enableEthernet //-----------------------------------------------------------------------------------numberOfSecondsSince1900Epoch unsigned long int numberOfSecondsSince1900Epoch(uint16_t y, uint8_t m, uint8_t d, uint8_t h, uint8_t mm, uint8_t s) { if (y >= 1970) y -= 1970; uint16_t daysLocal = d; for (uint8_t i = 1; i < m; ++i) daysLocal += daysInMonth[i - 1]; // for (uint8_t i = 1; i < m; ++i) // daysLocal += pgm_read_byte(daysInMonth + i - 1); if (m > 2 && y % 4 == 0) ++daysLocal; daysLocal += 365 * y + (y + 3) / 4 - 1; return daysLocal*24L*3600L + h*3600L + mm*60L + s + seventyYears; } //-----------------------------------------------------------------------------------processNTP void processNTP() { Udp.read(packetBuffer,NTP_PACKET_SIZE); IPAddress Remote = Udp.remoteIP(); int PortNum = Udp.remotePort(); /* if (debug) { Serial.println(); Serial.print("Received UDP packet size "); Serial.println(packetSize); Serial.print("From "); for (int i =0; i < 4; i++) { Serial.print(Remote[i], DEC); if (i < 3) { Serial.print("."); } } Serial.print(", port "); Serial.print(PortNum); byte LIVNMODE = packetBuffer[0]; Serial.print(" LI, Vers, Mode :"); Serial.print(packetBuffer[0],HEX); byte STRATUM = packetBuffer[1]; Serial.print(" Stratum :"); Serial.print(packetBuffer[1],HEX); byte POLLING = packetBuffer[2]; Serial.print(" Polling :"); Serial.print(packetBuffer[2],HEX); byte PRECISION = packetBuffer[3]; Serial.print(" Precision :"); Serial.println(packetBuffer[3],HEX); for (int z = 0; z < NTP_PACKET_SIZE; z++) { Serial.print(packetBuffer[z],HEX); if (((z+1) % 4) == 0) { Serial.println(); } } Serial.println(); } // end of debug statements */ packetBuffer[0] = 0b00100100; // LI, Version, Mode packetBuffer[1] = 1 ; // stratum packetBuffer[2] = 6 ; // polling minimum packetBuffer[3] = 0xFA; // precision packetBuffer[7] = 0; // root delay packetBuffer[8] = 0; packetBuffer[9] = 8; packetBuffer[10] = 0; packetBuffer[11] = 0; // root dispersion packetBuffer[12] = 0; packetBuffer[13] = 0xC; packetBuffer[14] = 0; /* uint16_t y=year(); uint8_t m=month(); uint8_t d=day(); uint8_t h=hour(); uint8_t mm=minute(); uint8_t s=second(); if (y >= 1970) y -= 1970; uint16_t daysLocal = d; for (uint8_t i = 1; i < m; ++i) daysLocal += daysInMonth[i - 1]; if (m > 2 && y % 4 == 0) ++daysLocal; daysLocal += 365 * y + (y + 3) / 4 - 1; timestamp1970 = daysLocal*24L*3600L + h*3600L + mm*60L + s + seventyYears; */ // uint16_t utcYY=year(); // uint8_t utcMM=month(); // uint8_t utcDD=day(); // uint8_t utchh=hour(); // uint8_t utcmm=minute(); // uint8_t utcss=second(); // timestamp1970 = numberOfSecondsSince1900Epoch(utcYY,utcMM,utcDD,utchh,utcmm,utcss); // timestamp1970 = numberOfSecondsSince1900Epoch(2022,4,30,10,10,10); timestamp1970 = numberOfSecondsSince1900Epoch(year(),month(),day(),hour(),minute(),second()); /* * timestamp1970 = numberOfSecondsSince1900Epoch( tinyGPS.date.year(), tinyGPS.date.month(), tinyGPS.date.day(), tinyGPS.time.hour(), tinyGPS.time.minute(), tinyGPS.time.second() ); */ unsigned long tempval = timestamp1970; packetBuffer[12] = 71; //"G"; packetBuffer[13] = 80; //"P"; packetBuffer[14] = 83; //"S"; packetBuffer[15] = 0; //"0"; // reference timestamp1970 packetBuffer[16] = (tempval >> 24) & 0XFF; tempval = timestamp1970; packetBuffer[17] = (tempval >> 16) & 0xFF; tempval = timestamp1970; packetBuffer[18] = (tempval >> 8) & 0xFF; tempval = timestamp1970; packetBuffer[19] = (tempval) & 0xFF; packetBuffer[20] = 0; packetBuffer[21] = 0; packetBuffer[22] = 0; packetBuffer[23] = 0; //copy originate timestamp from incoming UDP transmit timestamp packetBuffer[24] = packetBuffer[40]; packetBuffer[25] = packetBuffer[41]; packetBuffer[26] = packetBuffer[42]; packetBuffer[27] = packetBuffer[43]; packetBuffer[28] = packetBuffer[44]; packetBuffer[29] = packetBuffer[45]; packetBuffer[30] = packetBuffer[46]; packetBuffer[31] = packetBuffer[47]; //receive timestamp packetBuffer[32] = (tempval >> 24) & 0XFF; tempval = timestamp1970; packetBuffer[33] = (tempval >> 16) & 0xFF; tempval = timestamp1970; packetBuffer[34] = (tempval >> 8) & 0xFF; tempval = timestamp1970; packetBuffer[35] = (tempval) & 0xFF; packetBuffer[36] = 0; packetBuffer[37] = 0; packetBuffer[38] = 0; packetBuffer[39] = 0; //transmitt timestamp packetBuffer[40] = (tempval >> 24) & 0XFF; tempval = timestamp1970; packetBuffer[41] = (tempval >> 16) & 0xFF; tempval = timestamp1970; packetBuffer[42] = (tempval >> 8) & 0xFF; tempval = timestamp1970; packetBuffer[43] = (tempval) & 0xFF; packetBuffer[44] = 0; packetBuffer[45] = 0; packetBuffer[46] = 0; packetBuffer[47] = 0; // Reply to the IP address and port that sent the NTP request Udp.beginPacket(Remote, PortNum); Udp.write(packetBuffer,NTP_PACKET_SIZE); Udp.endPacket(); } #else void processNTP() {} #endif
  • Multi-radio per MCU

    5
    0 Votes
    5 Posts
    877 Views
    electrikE
    Look here: https://forum.mysensors.org/topic/11135/something-s-cooking-in-the-mysensors-labs?_=1665077470840
  • I got a plug-and-play NRF24 shield for the Pi on Aliexpress

    9
    0 Votes
    9 Posts
    3k Views
    puskyerP
    UPDATE: if at one point you need to use GPIO18 for something other then RF24L01 then you have to delete the spi-cs-extend.dtbo file from the /boot/overlays/ and then reboot.
  • JSN-SR04T-3.0 Ultrasonic - Please note

    1
    1 Votes
    1 Posts
    80 Views
    No one has replied
  • 0 Votes
    3 Posts
    89 Views
    M
    @OldSurferDude thank you so much for your reply, I’ll definitely look into this further! Martin
  • Need help for yacht lighting wireless switch

    3
    0 Votes
    3 Posts
    105 Views
    Damien 0D
    Thank you very mcuh for your reply, i'll defintely take a look to the sonoff devices if it can suits my need. In the same time regarding eclettis, i contacted them and their reply is that : *Our commands for home automation systems are simple normally open commands so they can be connected to every system. Just pay attention before connecting the device: ensure that the working voltage is properly configured in order to avoid to damage the device. * So i'm still looking in the same time for battery powered 4 way transmitter and corresponding receiver for DC system, on the top of that everything is dimmable led light...
  • Unknown Sensor

    2
    1
    0 Votes
    2 Posts
    74 Views
    V
    @chabo_mq Could this possibly be an IR light barrier?
  • I want to know what battery you use. How long can it be used?

    5
    0 Votes
    5 Posts
    125 Views
    NeverDieN
    @nagelc Yeah, that was me. I found it makes a difference.
  • Need help finding load cell, order qty would be > 32,000 units

    1
    0 Votes
    1 Posts
    39 Views
    No one has replied
  • TEMT6000 Breakout board

    6
    1
    0 Votes
    6 Posts
    196 Views
    dbrundD
    So the station is finally working, with the data being sent to googlesheets and integrated into Data Studio. [image: 1658446554681-2022-07-21_20h33_36.png]
  • nrf24+ module with stick antenna

    7
    1
    0 Votes
    7 Posts
    212 Views
    OldSurferDudeO
    @ben999 @NeverDie I had found a similar article about making the antenna a dipole. The interesting thing the article stressed was the lengths of the wires. I'm not an antenna engineer (my brother is) so I made the wires as suggested. I think it made a small improvement. and I still use that radio. My advice on antennas is: don't modify it. If your application needs more range, you're going to need more power. Signal strength drops off with the cube of the distance. So you're going to need a better antenna. For $3 (and a month or two delivery time) you can get a theoretically better module+antenna
  • Relay SSR AQH3223 vs AQH3223

    1
    0 Votes
    1 Posts
    35 Views
    No one has replied
  • How is this receiver able to continuously Rx but consume only 90ua?

    19
    0 Votes
    19 Posts
    894 Views
    NeverDieN
    A different link to the same thesis as previoiusly where he claims a wake-up distance of 20 meters: https://hh.diva-portal.org/smash/get/diva2:1187369/FULLTEXT02.pdf Well, it looks not difficult to construct. The AS3933 chips are available for around $1.30 on aliexpress, so cheaper than nRF5x chips. Perhaps cheapest of all would be be a tightly controlled nRF24L01, but it would surely draw more current listening than an AS3933.
  • MyS blocking i2c PCF8574

    mysensors
    13
    0 Votes
    13 Posts
    308 Views
    J
    final sketch and functional with MyController /* * DESCRIPTION : 4 inputs and 4 outputs on i2C bus with a PCF8574 * * LIBRAIRIES: * - Rob Tillaart pour PCF8574 https://github.com/RobTillaart/Arduino/tree/master/libraries/PCF8574 * - MySensors / Arduino Uno https://github.com/mysensors/MySensors * * ELEMENTS: * - Expander PCF8574 avec module Metasys JC / 4di 4do - 0X03D i2c adress * * MODIFICATION: * -x- RAS : Fonctionnelle * -o- * -o- * * (36%) de l'espace de stockage de programmes */ //----------- 9 Mai 2022 ---------------- PCF8574 -4DI-4DO / MyS RS485 et MyC -----------------// //------------------- MyS --------------------------------- //#define MY_DEBUG /*Enable debug prints to serial monitor*/ //#define MY_DEBUG_OTA_DISABLE_ECHO //testing #define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo de mis en Com (millisecondes) à placer avant Mysensors.h*/ #define MY_NODE_ID 40 /*Node en ID static*/ /* ----- Module TTL-RS485 ----*/ #define MY_RS485 /*Apl du transport RS485 (protocol?)*/ #define MY_RS485_DE_PIN 10 /*Cmd DE pin*/ #define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/ #define MY_REPEATER_FEATURE /*Activer fonctionnalité de répéteur du nœud*/ #include <MySensors.h> //---------------- PCF ------------------------------- #include "PCF8574.h" PCF8574 PCF27a (0x3D); // adjust addresses i2c pcf8574 // ------ objet ------ #define CHILD_ID_B0 0 /*Id IN - bp */ #define CHILD_ID_B1 1 #define CHILD_ID_B2 2 #define CHILD_ID_B3 3 #define CHILD_ID_R4 4 /*Id OUT - relay */ #define CHILD_ID_R5 5 #define CHILD_ID_R6 6 #define CHILD_ID_R7 7 #define RELAY_ON 0 // 1 valeur #define RELAY_OFF 1 // 0 invers //---------- MyS ------------- MyMessage msg0(CHILD_ID_B0,V_TRIPPED); /*Boton*/ MyMessage msg1(CHILD_ID_B1,V_TRIPPED); MyMessage msg2(CHILD_ID_B2,V_TRIPPED); MyMessage msg3(CHILD_ID_B3,V_TRIPPED); MyMessage msg4(CHILD_ID_R4,V_STATUS); /*Relay*/ MyMessage msg5(CHILD_ID_R5,V_STATUS); MyMessage msg6(CHILD_ID_R6,V_STATUS); MyMessage msg7(CHILD_ID_R7,V_STATUS); bool info; // pour info GW sur MyC bool state = false; // output // bool state4 = false; bool state5 = false; bool state6 = false; bool state7 = false; int oldValue0=-1; int oldValue1=-1; int oldValue2=-1; int oldValue3=-1; // Input //---------------- SETUP ------------------------- void setup() { // Serial.begin(115200); // debug //--------- testing IsConnected i2c PCfx ------------ Serial.println(__FILE__); Serial.print("PCF8574_LIB_VERSION:\t"); Serial.println(PCF8574_LIB_VERSION); if (!PCF27a.begin()) { Serial.println("could not initialize..."); } if (!PCF27a.isConnected()) { Serial.println("=> not connected"); } else { Serial.println("=> connected!!"); } // ---- info send to gateway ---- send(msg0.set(info)); send(msg1.set(info)); //input wait(200); send(msg2.set(info)); send(msg3.set(info)); //input wait(200); //delays for frames, depending on system load and bus type (wireless or wired) send(msg4.set(info)); send(msg5.set(info)); //output wait(200); send(msg6.set(info)); send(msg7.set(info)); //output } //----------------- MyS ---------------------------- void presentation() { sendSketchInfo("PCF8574 x4in/out - node40", "2.0"); /*info version sketch*/ /*Mysenors Enregistre Child sur la Gw*/ present(CHILD_ID_B0, S_DOOR, "boton0"); /*Boton*/ present(CHILD_ID_B1, S_DOOR, "boton1"); wait(200); present(CHILD_ID_B2, S_DOOR, "boton2"); present(CHILD_ID_B3, S_DOOR, "boton3"); wait(200); //delays for frames, depending on system load and bus type (wireless or wired) present(CHILD_ID_R4, S_BINARY, "relay4"); /*Relay*/ present(CHILD_ID_R5, S_BINARY, "relay5"); wait(200); present(CHILD_ID_R6, S_BINARY, "relay6"); present(CHILD_ID_R7, S_BINARY, "relay7"); wait(200); // metric = getControllerConfig().isMetric; } //----------------- LOOP ---------------------------- void loop() { //----------- MyS input ------------------------------- int value0 = PCF27a.read(0); if (value0 != oldValue0) { send(msg0.set(value0==HIGH ? 1 : 0)); //Send new value oldValue0 = value0; } int value1 = PCF27a.read(1); if (value1 != oldValue1) { send(msg1.set(value1==HIGH ? 1 : 0)); oldValue1 = value1; } int value2 = PCF27a.read(2); if (value2 != oldValue2) { send(msg2.set(value2==HIGH ? 1 : 0)); oldValue2 = value2; } int value3 = PCF27a.read(3); if (value3 != oldValue3) { send(msg3.set(value3==HIGH ? 1 : 0)); oldValue3 = value3; } } //----------- MyS out ------------------------------- void receive(const MyMessage &message) { if (message.getType()==V_STATUS) { switch (message.sensor) { case 4: state= message.getBool(); PCF27a.write(4, state?RELAY_ON:RELAY_OFF); break; case 5: state = message.getBool(); PCF27a.write(5, state?RELAY_ON:RELAY_OFF); break; case 6: state = message.getBool(); PCF27a.write(6, state?RELAY_ON:RELAY_OFF); break; case 7: state = message.getBool(); PCF27a.write(7, state?RELAY_ON:RELAY_OFF); break; } } } //------------------------------ End pgm -------------------------------------
  • Best PCB Assembly / Manufacturing for UK and Europe?

    1
    0 Votes
    1 Posts
    64 Views
    No one has replied
  • Reed Switch normally open or normally closed

    hardware 3d print
    20
    2 Votes
    20 Posts
    9k Views
    E
    i had good experience with it. . .
  • about Arduino + NRF24L01 need help please.

    5
    0 Votes
    5 Posts
    162 Views
    skywatchS
    @llasking Have a look on the arduino forum or github - I still use the older tmrh library for point-to-point on things made before I changed over to mysensors. There is also a nrf24-lite library as well, but I have never used it.
  • Mysensors exemple sketch on SAMD21 with i2c EEPROM

    1
    0 Votes
    1 Posts
    63 Views
    No one has replied
  • Reading INPUTS from arduino in domoticz

    7
    0 Votes
    7 Posts
    133 Views
    E
    @Mati_Smart, if the messages from the sensor are arriving in domoticz, it must be some configuration in domoticz itself. Can't help you here, I don't know domoticz. Did you search already on the domoticz forum?
  • CO2 Sensor Senseair S8 - big values read

    3
    0 Votes
    3 Posts
    113 Views
    epierreE
    maybe check what they did here: https://github.com/airgradienthq/arduino/blob/master/AirGradient.cpp

23

Online

11.7k

Users

11.2k

Topics

113.2k

Posts