@bjacobse to do proper ground and vcc planes you need a 4-layer PCB. Otherwise you won't get much of a difference in terms of EMI. Another way is to have 2 layer board and to have one layer only for ground plane, but that means you have to do all routing on one side, without making lines across your ground plane. Otherwise you decreasing grounding effect on EMI.
More on this topic in this free webinar: https://www.signalintegrityjournal.com/events/54-best-iot-board-design-practices-balancing-density-cost-low-power-and-mixed-signal

monte
@monte
Posts made by monte
-
RE: What did you build today (Pictures) ?
-
RE: Edit website's main page – show a really quick intro
@wofwca but isn't it indeed?
-
RE: idea: time child
@alowhum for now you could use S_INFO type and send alarm time in string with V_TEXT type. I believe most controllers do support S_INFO type on their side.
-
RE: What did you build today (Pictures) ?
Ask questions if something is left unclear.
#define DHT_PIN 4 #define CE_DISPLAY 5 #define RST_DISPLAY A2 #define DC_DISPLAY A3 #define DIN_DISPLAY 7 #define CLK_DISPLAY 8 #define SN "Clock + Temperature" #define SV "1.0" #define DHT_TYPE DHT22 #define MY_RADIO_NRF24 #define MY_TRANSPORT_WAIT_READY_MS 10000 #include <MySensors.h> #include <U8g2lib.h> #include <DHT.h> #include <time.h> volatile unsigned long rawTime; unsigned long timer1 = 0; unsigned long getTimeDelay = 600000; unsigned long timer2 = 0; int getDHTDelay = 3000; unsigned long timer3 = 0; unsigned int sendDelay = 60000; float h, t; char outdoorTemp[50]; float lastT; U8G2_PCD8544_84X48_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ CLK_DISPLAY, /* data=*/ DIN_DISPLAY, /* cs=*/ CE_DISPLAY, /* dc=*/ DC_DISPLAY, /* reset=*/ RST_DISPLAY); // Nokia 5110 Display DHT dht(DHT_PIN, DHT_TYPE); MyMessage tempMsg(0, V_TEMP); volatile struct tm * localTime; void before() { u8g2.begin(); Serial.begin(115200); u8g2.firstPage(); do { initScreen(); } while ( u8g2.nextPage() ); dht.begin(); delay(2000); } void setup() { setupTime(); timer1 = millis(); t = dht.readTemperature(); h = dht.readHumidity(); timer2 = millis(); send(tempMsg.set(t, 0)); lastT = t; timer3 = millis(); } void presentation() { present(0, S_TEMP); present(1, S_INFO); //Info sensor to request outdoor tempereture sendSketchInfo(SN, SV); request(1, V_TEXT); } void setupTime() //setting up timer and interrupt for seconds counter { cli(); //set timer1 interrupt at 1Hz TCCR1A = 0;// set entire TCCR1A register to 0 TCCR1B = 0;// same for TCCR1B TCNT1 = 0;//initialize counter value to 0 // set compare match register for 1hz increments OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536) // turn on CTC mode TCCR1B |= (1 << WGM12); // Set CS10 and CS12 bits for 1024 prescaler TCCR1B |= (1 << CS12) | (1 << CS10); // enable timer compare interrupt TIMSK1 |= (1 << OCIE1A); sei(); requestTime(); } ISR(TIMER1_COMPA_vect) { rawTime++; //increment seconds counter } void float2string(float n, char* output) { char aChar[5]; char bChar[4]; if (n > 0.0) { strcpy(aChar, "+"); } else if (n < 0.0) { strcpy(aChar, "-"); } dtostrf(n, 4, 1, bChar); sprintf(output, "%s%s", aChar, bChar); } void initScreen() //function to show message on screen during node start { u8g2.setFont(u8g2_font_profont12_tr); u8g2.drawStr(42 - (u8g2.getStrWidth("Connecting to") / 2), 13, "Connecting to"); u8g2.drawStr(42 - (u8g2.getStrWidth("a MySensors") / 2), 26, "a MySensors"); u8g2.drawStr(42 - (u8g2.getStrWidth("network.") / 2), 39, "network"); } void mainScreen() { u8g2.setDrawColor(1); u8g2.setFontMode(1); u8g2.drawBox(0, 0, 84, 8); u8g2.setDrawColor(0); u8g2.setFont(u8g2_font_profont10_tf); localTime = localtime(&rawTime); //using standart AVR time.h library to convert seconds counter into local time char date[30]; strftime(date, 30, "%d.%m.%y %R", localTime); //constructing a string with date and time u8g2.drawStr(42 - (u8g2.getStrWidth(date) / 2), 7, date); u8g2.setDrawColor(1); u8g2.setFont(u8g2_font_maniac_tr); char val[5]; float2string(t, val); //converting float value from dht11 to a string u8g2.drawStr(42 - (u8g2.getStrWidth(val) / 2), 36, val); u8g2.setFont(u8g2_font_profont10_tf); u8g2.drawStr(5, 47, outdoorTemp); itoa((int)h, val, 10); //I don't need precision for humidity procentage, otherwise you can use dtostrf() u8g2.drawStr(70 - u8g2.getStrWidth(val), 47, val); u8g2.setFont(u8g2_font_open_iconic_thing_1x_t); u8g2.drawStr(71, 47, "\x48"); } boolean isTime(unsigned long *timeMark, unsigned long timeInterval) //time counter function for non-blocking delays { if (millis() - *timeMark >= timeInterval) { *timeMark = millis(); return true; } return false; } void loop() { if (isTime(&timer1, getTimeDelay)) { //request time from controller once in 10 minutes requestTime(); } if (isTime(&timer2, getDHTDelay)) { //polling DHT sensor and printing values to serial t = dht.readTemperature(); h = dht.readHumidity(); Serial.print("Temperature: "); Serial.print(t); Serial.println("°"); Serial.print("Humidity: "); Serial.print(h); Serial.println("%"); } if (isTime(&timer3, sendDelay)) { //sending temperature to controller once in 30 seconds if (t != lastT) { send(tempMsg.set(t, 0)); request(1, V_TEXT); lastT = t; } } u8g2.firstPage(); //this section is for screen handling do { mainScreen(); } while ( u8g2.nextPage() ); } void receive(const MyMessage &message) //receiving an outdoor reading from the controller and constructing a string to display { if (message.type == V_TEXT) { sprintf(outdoorTemp, "%sC%s", message.getString(), "\xb0"); } } void receiveTime(uint32_t ts) { rawTime = ts - UNIX_OFFSET; //substructing an offset from received timestamp, since time.h doesn't use Unix count localTime = localtime(&rawTime); //updating seconds timer with accurate value timer1 = millis(); }
-
RE: What did you build today (Pictures) ?
Build myself a simple temperature sensor with a clock. No RTC, just pulling time from controller and updating every 10 minutes to avoid drift. Also requesting outdoor temperature from controller. Build from what was lying around - DHT22, pro mini clone, nokia screen. I can share the code if someone needs it
-
RE: Everything nRF52840
@neverdie YAY for transport-agnostic mysensors-python-edition!
-
RE: What did you build today (Pictures) ?
@nca78 said in What did you build today (Pictures) ?:
Unfortunately most of the cheap breakout boards found on AliExpress use clones with much worse specs than the original version
Could you be more specific? How exactly worth specs does they have. Was going to buy a bunch of them. Maybe there is some comparison or tests?
-
RE: What did you build today (Pictures) ?
@sundberg84 I've bought these 5032 crystals: https://www.aliexpress.com/item/Free-shipping-20pcs-16-000MHZ-16mhz-20pF-2Pin-5032-smd-quartz-resonator-Crystal/32821974003.html but there are plentiful other offers on aliexspress and/or ebay. This 5032 package seems to be the most common. There is another package with the same size but with 4 pins 2 of which are not connected, I bought them from my local distributor, while was waiting a package from aliexpress. But those with 4 pins are harder to solder (obviously) and I don't see any pros of using them.
The most suitable for hand soldering and easiest to find are these:
According to this image the ones I have are TX5 and TG5. -
RE: What did you build today (Pictures) ?
@sundberg84 you can also use smd crystal. They are cheaply available on aliexpress. Are you using 0603 caps and resistors?
-
RE: nRF5 action!
@toyman no, if your code is in python. So the deal is "just" to port mysensors to python.