lexus2k / ssd1306

Driver for SSD1306, SSD1331, SSD1351, IL9163, ILI9341, ST7735, PCD8544, Nokia 5110 displays running on Arduino/ESP32/Linux (Rasperry) platforms
MIT License
651 stars 125 forks source link

433MHz transmission trouble with pcd8544 #122

Closed philippedc closed 2 years ago

philippedc commented 3 years ago

Hi, I have several small projects running with Atmega328p and FS1000A / WL101 433MHz transmission : they detect a letter in box, the water level in tanks, etc.... Since now I used the OLED ssd1306 display for the receiver, but I thought better to replace them by Nokia 5110 just because the display is always on with a low power consumtion. But I have a problem: by simply adapting the code from ssd1306 (driven by I2C) to pcd8544 ( driven by MOSI) makes the radio receiver losing the message from time to time. All messages are short, 7 bytes maxi. Sometime the message is received (and treated by the code) but sometime nothing happens. For the radio transmission I use the very classical VirtualWire library (http://www.airspayce.com/mikem/arduino/VirtualWire).

About the receiver: If some information is lost in reception, it may be because the process to update the display is much more longer for a pcd8544 than for a ssd1306. Actual code makes the display completely updated every seconds, even for the ":" blink in the time display... Of course I will modify the code, so that only the place that need a change is updated. However, I would like some confirmation from you.... Can you confirm that the delay needed to update a display is much longer for a pcd8544 than for a ssd1306 ? If yes approx how much time longer ? If no, have you got an idea of the origin of the problem ?

About the transmitter: I had the idea to add a pcd8544 with a radio transmitter. First, I had to take care in the order to declare in setup:

// initialise the IO and ISR of the radio transmitter vw_set_tx_pin(radioPin); // transmitter initialization vw_setup(2000); // transmission bits per seconds delay(1000);

// lcd initialization ssd1306_setFixedFont(ssd1306xled_font6x8); //pcd8544_84x48_spi_init(int8_t rstPin, int8_t scePin, int8_t dcPin); pcd8544_84x48_spi_init(3, 4, 5); ssd1306_clearScreen(); ssd1306_printFixed (0, 0, "demarrage...", STYLE_NORMAL); delay(1000); ssd1306_clearScreen();

if I start by declaring the lcd first and then radio the lcd does not work (I don't know about the radio). But if I declare radio first and then the lcd, the lcd works but not the radio. Is it because both use serial ? How can I work around this ? Thanks,

lexus2k commented 3 years ago

Hi Philippe,

Can you confirm that the delay needed to update a display is much longer for a pcd8544 than for a ssd1306 ? If yes approx how much time longer ?

I do not confirm that. pcd8544 works over SPI at default 8 MHz baud rate, while ssd1306 works over I2C at 400 kHz. So, pcd8544 interface should be almost 20 times faster. I'm not familiar with VirtualWire library, but they say For testing purposes you can connect 2 VirtualWire instances directly, by connecting pin 12 of one to 11 of the other and vice versa, like this for a duplex connection . So, I would advise you to check used pins in your project, because the same pins 11,12,13 on Atmega328p are usually used for SPI to communicate with lcd displays.

For example, you have pcd855 initialization like this: pcd8544_84x48_spi_init(3, 4, 5);, where 3, 4, 5 are RST, CS, D/C pins, but 11/13 pins are used implicitly by SPI bus. RF module is initialized like vw_set_tx_pin(radioPin) in your code, radioPin value is unknown for me. I hope that you use some radioPin not related to SPI bus.

Next thing to check is timers/interrupts. Actually, ssd1306 library do not use any interrupts, and works via standard SPI interface. cli/sei are used only for i2c software implementation and that code is not used for pcd8544.

How does your loop cycle look like? Are there any delays in main program loop?

Best regards

philippedc commented 3 years ago

For testing purposes you can connect 2 VirtualWire instances directly, by connecting pin 12 of one to 11 of the other and vice versa, like this for a duplex connection . So, I would advise you to check used pins in your project, because the same pins 11,12,13 on Atmega328p are usually used for SPI to communicate with lcd displays.

yes indeed I don't understand this testing purpose upon 2 wires as there is only 1 wire to go to the 433MHz transmitter, and also one wire coming from the receiver.... I made examples code with transmitter pin (radioPin) #12 or #2 So it looks like a conflict in the SPI protocol. I can confirm the problem keeps the same once I considerably optimized the display functions of the code. In fact in the manual the transmitter is pin #12 and receiver pin #11. I suppose that even if these pins are remapped the default pins stay unusable for something else :(

Here is the code : /* 433MHz receiver for the openned_mailbox_detector

from an idea of : https://www.carnetdumaker.net/articles/communiquer-sans-fil-en-433mhz-avec-la-bibliotheque-virtualwire-et-une-carte-arduino-genuino/

THE VirtualWire LIBRARY DOES NOT WORK WITH ATtiny85

Arduino Uno / ATmega328P wiring :


A5 = PC5 in pin28 => SCL for SSD1306 OLED and DS1307 RTC + 24C32 EEPROM A4 = PC4 in pin27 => SDA for SSD1306 OLED and DS1307 RTC + 24C32 EEPROM 12 = PB4 in pin18 => any traffic LED light 10 = PB2 in pin16 => PCD8544 retro leds 9 = PB1 in pin15 => DHT11 + 4.7Ko wired to Vcc 8 = PB0 in pin14 => mailbox traffic buzzer 7 = PD7 in pin13 => push button to set time and display change 2 = PD2 in pin4 => data from 433MHz receiver

13 = PB5 in pin19 => PCD8544 SCLK (default atmega328p SCK) 11 = PB3 in pin17 => PCD8544 DN (default atmega328p MOSI) 5 = PD5 in pin11 => PCD8544 D/C 4 = PD4 in pin6 => PCD8544 SCE (option: may pull down SCE to GND) 3 = PD3 in pin5 => PCD8544 RST

history v5.0 - 15 dec 2020 - adaptation from ssd1306 oled to Nokia 5110 permanent display V5.1 - 17 jan 2021 - modify the change time process and display bug correction V6.0 - 23 jan 2021 - workarround by minimazing the display process */

// DS1307 addresses const uint8_t DS1307_ADDRESS = 0x68; const uint8_t DS1307_NVRAM_BASE = 0x08;

include // https://github.com/rocketscream/Low-Power

include // http://www.airspayce.com/mikem/arduino/VirtualWire/

include "ssd1306.h" // https://github.com/lexus2k/ssd1306

include // https://github.com/PaulStoffregen/Time

include // https://github.com/PaulStoffregen/DS1307RTC

include // https://github.com/adafruit/DHT-sensor-library

                      // https://github.com/adafruit/Adafruit_Sensor

include // allow to direct communication with DS1307

define RX_pin 2

define pb_pin 7

define buz_pin 8

define dht_pin 9

define lightPin 10

define led_pin 12

// Create the DHT instance DHT dht(dht_pin, DHT11);

int t0=0, memo_t0=0, h0; int t1=0, memo_t1=0, h1; int t2=0, memo_t2=0, h2; int v0, v1, v2; char heure[10]; // 1st line of display : the day of week + time char th0[16]; // 2nd line of display : local temperature + hygrometry char th1[16]; // 2nd line of display : outside temperature + hygrometry char th2[16]; // alternatively the 2nd line of display : inside temperature + hygrometry char line0[16], line1[16], line2[16]; // events display lines char mail0[16], mail1[16], mail2[16]; // mail box events lines char volt0[16], volt1[16], volt2[16]; // measured supply voltage of devices char jour[7][3] = {"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"};

// specific symbols to display: const PROGMEM byte degree[3] = { 0b00000010, 0b00000101, 0b00000010 }; const PROGMEM byte fleche[3][5] = { { 0b00001000, 0b00001100, 0b01111110, 0b00001100, 0b00001000 }, { 0b00010000, 0b00110000, 0b01111110, 0b00110000, 0b00100000 }, { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 } };

SPRITE symbol; // define non ascii characters: degree + arrow fletches SPRITE tendancy; // Declare a variable that represents our sprite

bool button = HIGH, memo_button = HIGH, memo_memo_button = HIGH; bool deuxpoints = true; bool mailbox = false; // mail received bool sensorT1 = false, sensorT2 = false, altern = LOW; // temperatures received bool otherword = false; // if message received if from another format byte seconds = 60, minutes = 60, hours = 24; bool voltdisplay = false, memo_voltdisplay = false; unsigned int timerT1 = 0, timerT2 = 0;

time_t t; // number of second since 1970 int drift = 0; // initial value of the time drift bool summer = false; // define if winter or summer time

// // SETUP //____

void setup() {

pinMode( pb_pin, INPUT_PULLUP ); pinMode( buz_pin, OUTPUT); pinMode( led_pin, OUTPUT); pinMode( lightPin, OUTPUT);

for( byte i=0; i<3; i++ ) { BlinkLed(); delay(500); }

// Initialize the lcd display & console ssd1306_setFixedFont(ssd1306xled_font6x8); //pcd8544_84x48_spi_init(int8_t rstPin, int8_t scePin, int8_t dcPin); pcd8544_84x48_spi_init(3, 4, 5);

ssd1306_clearScreen(); ssd1306_printFixed (0, 0, "demarrage...", STYLE_NORMAL);

//Serial.begin(9600); // Debugging only //Serial.println("start....."); delay(1000);

// Initialise the IO and ISR vw_set_rx_pin(RX_pin); vw_setup(2000); // Bits par sec vw_rx_start();

// Initialize the time and date from DS1307 setSyncProvider(RTC.get); // the function to get the time from the RTC t = now(); // get the RTC number of seconds of time since 1970 unsigned long ActualTime = t;

// get DS1307 NVRAM data Wire.begin(); const byte driftOffset = 30; byte Fcell0 = ReadNVRAM(0); byte Fcell1 = ReadNVRAM(1); byte Fday = ReadNVRAM(4); byte Fmonth = ReadNVRAM(3); byte Fyear = ReadNVRAM(2); byte Fhour = ReadNVRAM(5); byte Fminute = ReadNVRAM(6); byte Fsecond = ReadNVRAM(7); drift = ReadNVRAM(8) - driftOffset;

// calculate the number of days since the drift setting operation if((Fcell0 == 1) && (Fcell1 == 1)) { // DS1307 drift operation has been done setTime(Fhour, Fminute, Fsecond, Fday, Fmonth, Fyear); t = now(); unsigned long FTime = t; unsigned int NumberOfDays = (ActualTime - FTime) / 86400; ActualTime -= (drift * NumberOfDays); setTime(ActualTime); // update system time summer = SummerTime(); // winter or summer time } else if( timeStatus()!= timeSet ) TimeSetup(); // set the date & time if needed

dht.begin(); // initialise the DHT11 sensor

tone(buz_pin, 500, 200); delay(200); tone(buz_pin, 800, 200); delay(200); for( byte j=0; j<15; j++ ) { mail0[j]=' '; mail1[j]=' '; mail2[j] = ' '; }

ssd1306_clearScreen(); }

// // LOOP //____

void loop() {

// if low battery: stop all except the blinking LED every seconds static bool LOWBAT = false; static bool EXTLOWBAT = false; static byte i = 0; if( LOWBAT ) { ssd1306_clearScreen(); ssd1306_displayOff(); BlinkLed(); LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); // < 1.30mA if( ++i > 60 ) { i = 0; if( readVcc() > 37 ) { LOWBAT = false; ssd1306_displayOn(); } } return; }

// check if a message is received uint8_t buf[8]; //VW_MAX_MESSAGE_LEN]; uint8_t buflen = 8; //VW_MAX_MESSAGE_LEN;

bool mailbox = false; // reset display update flag

if(vw_get_message(buf, &buflen)) {

/// for debugging : TimeFormat(); Serial.print(heure); Serial.print(" What is received : "); for(byte i=0; i<buflen; i++) Serial.write(buf[i]); Serial.println(); tone(buz_pin, 500, 200); delay(200); /

BlinkLed();
switch( buf[0] ) {
  case 'L':
    mailbox = true;
    for( byte i=0; i<14; i++ ) {
      mail2[i] = mail1[i]; mail1[i] = mail0[i];
    }
    mail0[0] = 'L'; mail0[1] = '-'; mail0[2] = ' ';
    for( byte i=0; i<9; i++ ) mail0[i+3] = heure[i];
    tone(buz_pin, 500, 200); delay(200); tone(buz_pin, 800, 200); delay(200);
    break;

  case 'B':
    mailbox = true;
    for( byte i=0; i<14; i++ ) {
      mail2[i] = mail1[i]; mail1[i] = mail0[i];
    }
    mail0[0] = 'B'; mail0[1] = '-'; mail0[2] = ' ';
    for( byte i=0; i<9; i++ ) mail0[i+3] = heure[i];
    tone(buz_pin, 500, 200); delay(200); tone(buz_pin, 800, 200); delay(200);
    break;

  case 'T':
    sensorT1 = true;
    timerT1 = 0;                                   // timer marker of last data receive
    memo_t1 = t1;
    t1 = (int)(buf[2]*100 + buf[3]*10 + buf[5]);   // get the value of temp
    if( buf[5] > 5) t1 += 5;                       // round decimal number
    if( buf[1] == '-' ) t1 = -t1;
    th1[0] = 'E'; th1[1] = 'x'; th1[2] = 't'; th1[3] = ':'; 
    th1[4] = buf[1]; th1[5] = buf[2]; th1[6] = buf[3];
    //th1[5] = buf[4]; th1[6] = buf[5];
    th1[7] = ' '; th1[8] = 'C';
    th1[9] = ' '; th1[10] = ' ';
    break;

  case 'H':
    h1 = (int)(buf[1]*10 + buf[2]);                     
    th1[11] = buf[1]; th1[12] = buf[2];            // make the display message
    th1[13] = '%';
    break;

  case 'U':
    sensorT2 = true;
    timerT2 = 0;                                   // timer marker of last data receive
    memo_t2 = t2;
    t2 = (int)(buf[2]*100 + buf[3]*10 + buf[5]);   // get the value of temp
    if( buf[5] > 5) t1 += 5;                       // round decimal number
    if( buf[1] == '-' ) t2 = -t2;
    th2[0] = 'I'; th2[1] = 'n'; th2[2] = 't'; th2[3] = ':';
    th2[4] = buf[1]; th2[5] = buf[2]; th2[6] = buf[3];
    //th2[5] = buf[4]; th2[6] = buf[5];
    th2[7] = ' '; th2[8] = 'C'; 
    th2[9] = ' '; th2[10] = ' ';
    break;

  case 'I':
    h2 = (int)(buf[1]*10 + buf[2]);                          // get the value of hygro
    th2[11] = buf[1]; th2[12] = buf[2];
    th2[13] = '%';
    break;

  case 'V':
    volt1[0] = 'V'; volt1[1] = 'e'; volt1[2] = 'x'; volt1[3] = 't';    
    volt1[4] = ' '; volt1[5] = '='; volt1[6] = ' ';
    volt1[7] = buf[1]; volt1[8] = '.'; volt1[9] = buf[2]; volt1[10] = 'V';
    volt1[11] = ' ';
    break;

  case 'W':
    volt2[0] = 'V'; volt2[1] = 'i'; volt2[2] = 'n'; volt2[3] = 't';    
    volt2[4] = ' '; volt2[5] = '='; volt2[6] = ' ';
    volt2[7] = buf[1]; volt2[8] = '.'; volt2[9] = buf[2]; volt2[10] = 'V';
    volt2[11] = ' ';
    break;

  default: 
    otherword = true;
    break;
}  // end of switch

} // end of if(vw_get_message(buf, &buflen))

// the second part of the code is done every seccond //___ static byte tempo = 0; if( seconds == second() ) return; seconds = second(); deuxpoints =! deuxpoints; // alternatively true then false each second if( deuxpoints == true ) ssd1306_printFixed (52, 0, ":", STYLE_NORMAL); else ssd1306_printFixed (52, 0, " ", STYLE_NORMAL);

// push button management memo_voltdisplay = voltdisplay; memo_memo_button = memo_button; memo_button = button; button = digitalRead(pb_pin); // active = LOW if( !button ) { tempo = 0; Afficher('n'); voltdisplay =! voltdisplay; digitalWrite( lightPin, HIGH ); if( !memo_button && !memo_memo_button ) TimeSetup(); // if button push delay of 3 secondes }

// return to default display if( tempo == 4 ) { digitalWrite( lightPin, LOW ); Afficher('n'); } if( ++tempo > 120 ) { tempo = 0; voltdisplay = false; }

// voltage display vs mailbox activity display if( voltdisplay != memo_voltdisplay ) { if( voltdisplay ) { for( byte j=0; j<15; j++ ) { line2[j] = volt0[j]; line1[j] = volt1[j]; line0[j] = volt2[j]; } } else { for( byte j=0; j<15; j++ ) { line2[j] = mail2[j]; line1[j] = mail1[j]; line0[j] = mail0[j]; } } Afficher('d'); }

// update the display according to radio message if(mailbox) { mailbox = false; Afficher('d'); } if(otherword) { otherword = false; tempo = 0; Afficher('o'); }

if((tempo %5)==0 ) { if( sensorT1 && sensorT2 ) altern = !altern; else if( sensorT2 ) altern = HIGH; else altern = LOW; Afficher('t'); }

// what is done every minute //___ if( minutes == minute() ) return; minutes = minute();

// get local device temperature memo_t0 = t0; t0 = 10* dht.readTemperature(); h0 = dht.readHumidity(); v0 = readVcc();

volt0[0] = 'V'; volt0[1] = 'l'; volt0[2] = 'o'; volt0[3] = 'c';
volt0[4] = ' '; volt0[5] = '='; volt0[6] = ' '; volt0[7] = v0/10 +48; volt0[8] = '.'; volt0[9] = v0%10 +48; volt0[10] = 'V'; volt0[11] = ' ';

th0[0] = 'L'; th0[1] = 'o'; th0[2] = 'c'; th0[3] = ':'; th0[4] = ' '; th0[5] = t0/100 +48; t0 = t0%100; th0[6] = t0/10 +48; //th0[5] = '.'; th0[6] = t0%10 +48;
th0[7] = ' '; th0[8] = 'C'; th0[9] = ' '; th0[10] = ' '; th0[11] = h0/10 +48; th0[12] = h0%10 +48; th0[13] = '%';

// disable display content if no update if( sensorT1 && (++timerT1 > 30)) { for( byte i=0; i<15; i++ ) th1[i] = ' '; //exterieur = false; sensorT1 = false; } if( sensorT2 && (++timerT2 > 30)) { for( byte i=0; i<15; i++ ) th2[i] = ' '; //interieur = false; sensorT2 = false; }

// battery level alarm for remote devices if( EXTLOWBAT ) BlinkLed();

// define the time TimeFormat();

// display on lcd Afficher('u');

// what is done every hour //___ if( hours == hour() ) return; hours = hour();

// check if low battery v0 = readVcc(); if( v0 < 37 ) LOWBAT = true;

v1 = (volt1[7]10 -48) + volt1[9] -48; v2 = (volt2[7]10 -48) + volt2[9] -48; if((v1 > 0 && v1 < 37) || (v2 > 0 && v2 < 37)) EXTLOWBAT = true; else EXTLOWBAT = false;

// automatic drift ajust time & adjust summer/winter time once per day static bool onceDay = true; if((hour() == 1) && onceDay) { onceDay = false; t = now(); t -= drift; // update the number of seconds since 1970... setTime(t); // update system time

bool isSummerNow = SummerTime();
if( !summer && isSummerNow ) {
  adjustTime(3600);
}
else if( summer && !isSummerNow ) {
  adjustTime(-3600);
}
summer = isSummerNow;

} // end of test onceDay else if( hour() == 2 ) onceDay = 1;

} // end of loop()

//============================================================================================ // list of functions //============================================================================================

// // BlinkLed() : function to blink the traffic led //____

void BlinkLed() { digitalWrite( led_pin, HIGH); delay(5); digitalWrite( led_pin, LOW); }

// // ReadNVRAM() : function to read DS1307 NVRAM 56 bytes memory //____

int ReadNVRAM(byte address) {

Wire.beginTransmission(DS1307_ADDRESS); Wire.write(DS1307_NVRAM_BASE + address); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, (byte) 1); return Wire.read(); }

// // WriteNVRAM() : function to write in DS1307 NVRAM 56 bytes memory //____

void WriteNVRAM(byte address, byte data) {

Wire.beginTransmission(DS1307_ADDRESS); Wire.write(DS1307_NVRAM_BASE + address); Wire.write(data); Wire.endTransmission(); // Fin de transaction I2C }

// // Afficher() : function to set the display //____

void Afficher( char w ) { // w = o => flag if unknown message received // t => update temperature only // u => show up part of the display // d => show down part of the display

switch(w) {

// set the up part of the display //------------------------------- case 'o': ssd1306_printFixed (0, 0, "*", STYLE_NORMAL); break; case 'n': ssd1306_printFixed (0, 0, " ", STYLE_NORMAL); break; case 'u': // set time ssd1306_printFixed (8, 0, "-", STYLE_BOLD); ssd1306_printFixed (16, 0, heure, STYLE_BOLD); ssd1306_printFixed (72, 0, "-", STYLE_BOLD);

// display local temperature & set tendancy
if( t0 != memo_t0 ) {             // only if t0 has changed
  static byte TENDANCY0 = 2;      // default value is no increase nor decrease
  ssd1306_printFixed (0,  8, th0,  STYLE_NORMAL);
  if( t0 > memo_t0 )      TENDANCY0 = 0;  //th0[9] = '+';
  else if( t0 < memo_t0 ) TENDANCY0 = 1;  //th0[9] = '-';
  symbol = ssd1306_createSprite( 44, 8, 3, degree );
  symbol.draw();
  tendancy = ssd1306_createSprite( 54, 8, 5, fleche[TENDANCY0] );
  tendancy.draw();
}

case 't': static byte TENDANCYx = 2; // default value is no increase nor decrease if( altern ) { ssd1306_printFixed (0, 16, th2, STYLE_NORMAL); if( sensorT2 ) { if( t2 > memo_t2 ) TENDANCYx = 0; //th2[9] = '+'; else if( t2 < memo_t2 ) TENDANCYx = 1; //th2[9] = '-'; symbol = ssd1306_createSprite( 44, 16, 3, degree ); symbol.draw(); tendancy = ssd1306_createSprite( 54, 16, 5, fleche[TENDANCYx] ); tendancy.draw(); } } else { ssd1306_printFixed (0, 16, th1, STYLE_NORMAL); if( sensorT1 ) { if( t1 > memo_t1 ) TENDANCYx = 0; //th1[9] = '+'; else if( t1 < memo_t1 ) TENDANCYx = 1; //th1[9] = '-'; symbol = ssd1306_createSprite( 44, 16, 3, degree ); symbol.draw(); tendancy = ssd1306_createSprite( 54, 16, 5, fleche[TENDANCYx] ); tendancy.draw(); } } break;

// set the down part of the display //--------------------------------- case 'd': ssd1306_printFixed (10, 24, line2, STYLE_ITALIC); ssd1306_printFixed (10, 32, line1, STYLE_ITALIC); ssd1306_printFixed (10, 40, line0, STYLE_ITALIC); } // end of case } // end of Afficher()

// // SummerTime() : define if winter or summer time //____

bool SummerTime() { int mois = month(); int jour = day(); int joursemaine = weekday(); if( (mois > 3 && mois < 10) || (mois == 3 && (jour - joursemaine) > 22 ) || (mois == 10 && (jour - joursemaine) < 23 ) ) return true; else return false;
}

// // TimeFormat : function to set date and time //____

void TimeFormat() { for( byte i=0; i<3; i++ ) heure[i] = jour[weekday()-1][i]; heure[3] = ' '; if( hour() < 10 ) heure[4] = '0'; else heure[4] = hour()/10 +48; heure[5] = hour()%10 +48; heure[6] = ':'; if( minute() < 10 ) heure[7] = '0'; else heure[7] = minute()/10 +48; heure[8] = minute()%10 +48; }

// // TimeSetup : function to set date and time //____

void TimeSetup() { time_t t = now(); // Get the time from DS1307 to t unsigned long ajust[] = { 86400, 3600, 60 }; // 1 day, 1 hour, 1 minute in seconds for( byte d=0; d<3; d++ ) { ssd1306_clearScreen(); while( true ) {
if( seconds != second() ) { seconds = second(); memo_memo_button = memo_button; deuxpoints =! deuxpoints; memo_button = button; button = digitalRead(pb_pin);; if((memo_memo_button == LOW)&&(memo_button == LOW)&&(button == LOW)) break; else if((memo_memo_button == HIGH)&&(memo_button == LOW)&&(button == HIGH)) { t += ajust[d]; //RTC.set(t); // set the RTC and the system time to the new value setTime(t); // set the system time (different than RTC time) } } // end of test on seconds TimeFormat(); ssd1306_printFixed (0, 0, "Appuit court= ", STYLE_NORMAL); switch(d) { case 0: ssd1306_printFixed (0, 8, "change le jour", STYLE_NORMAL); break; case 1: ssd1306_printFixed (0, 8, "change heures ", STYLE_NORMAL); break; case 2: ssd1306_printFixed (0, 8, "change minutes", STYLE_NORMAL); break; } if( deuxpoints == true ) ssd1306_printFixed (0, 24, heure, STYLE_BOLD); else ssd1306_printFixed (0, 24, heure, STYLE_NORMAL); ssd1306_printFixed (0, 40, "long= valide ", STYLE_ITALIC); } // end of while } // end of for ssd1306_clearScreen(); } // end of timeSetup()

// // readVccp : function to read the power supply voltage //____

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__)

ADMUX = _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;

// autre écriture possible : // result = ADCL; // result |= ADCH<<8;

//result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.110231000 result = 11253L / result; // Calculate Vcc in dV (decivolt) return result; // Vcc in millivolts }

lexus2k commented 3 years ago

Hi

A5 = PC5 in pin28 => SCL for SSD1306 OLED and DS1307 RTC + 24C32 EEPROM
A4 = PC4 in pin27 => SDA for SSD1306 OLED and DS1307 RTC + 24C32 EEPROM
12 = PB4 in pin18 => any traffic LED light
10 = PB2 in pin16 => PCD8544 retro leds
9 = PB1 in pin15 => DHT11 + 4.7Ko wired to Vcc
8 = PB0 in pin14 => mailbox traffic buzzer
7 = PD7 in pin13 => push button to set time and display change
2 = PD2 in pin4 => data from 433MHz receiver

13 = PB5 in pin19 => PCD8544 SCLK (default atmega328p SCK)
11 = PB3 in pin17 => PCD8544 DN (default atmega328p MOSI)
5 = PD5 in pin11 => PCD8544 D/C
4 = PD4 in pin6 => PCD8544 SCE (option: may pull down SCE to GND)
3 = PD3 in pin5 => PCD8544 RST

Digital output 12 is still in use by standard SPI MISO. That can affect traffic LED. I don't think that there is conflict between ssd1306 library and Digital pin 2, used for 433MHz receiver.