Arduino Datalogger With RTC, Nokia LCD and Encoder

8,074

35

14

Introduction: Arduino Datalogger With RTC, Nokia LCD and Encoder

Parts:

  • Arduino Nano or Arduino Pro Mini
  • Nokia 5110 84x48 LCD
  • DHT11 temperature/humidity sensor
  • DS1307 or DS3231 RTC module with built-in AT24C32 EEPROM
  • Cheap encoder with 3 debouncing capacitors

Features:

  • GUI based on Nokia LCD and encoder
  • temperature, humidity, date and time can be stored every 1 to 120 minutes
  • each record is compressed to 39 bitfield only so 32kbit flash (4KB) can fit 819 records
  • optional AT24C256 chip can store even 6553 records
  • deep sleep used to save battery, ATMEGA is woken up by interrupts mainly
  • DHT11 is powered only during measurements
  • powered by single 18650 or other lithium cell
  • a few display "faces"
  • 6 fonts
  • battery level meter
  • data review and graphs
  • min/max with date/time
  • all recorded data dump via serial port in CSV format
  • LCD back light
  • own fast and low resource N5110 library used
  • own low level DHT11 data reading
  • own DS1307, DS3231 and AT24C32 I2C EEPROM handling code
  • the code uses almost all 32KB Arduino flash
  • all internal registers can be stored in external EEPROM or DS1307 internal RAM

Data compression

Following values are recorded:

  • time (hr,min)
  • date (d,m,y)
  • temperature
  • humidity

Above data is compressed to 39-bit bitfield:

  • hr 0..23 -> 5b
  • min 0..59 -> 6b
  • d 1..31 -> 5b
  • m 1..12 -> 4b
  • y 2018..2021 -> 2b
  • temp -40.0..64.0 -> 1024values = 10b
  • hum 0..100 -> 7b
  • total 39 bits

Only 5 bytes are used for 1 record:

bits   76543210    
byte0 hhhhhmmm byte1 mmmddddd byte2 mmmmyytt byte3 tttttttt byte4 hhhhhhh0

Step 1: Watch Videos

If you are interested in project features and development watch above videos

Step 2: Connections

Nokia 5110:

  1. RST to D9
  2. CS/CE to D10
  3. DC to D8
  4. MOSI/DIN to D11
  5. SCK/CLK to D13
  6. VCC to Arduino VCC
  7. LIGHT to D6
  8. GND to GND

DHT11:

  1. VCC to VCC
  2. DATA to D14
  3. NC
  4. GND to GND

RTC DS1307/DS3231 and AT24C32 EEPROM:

  • Arduino I2C (A4/A5)

Encoder:

  • PinA to D2
  • PinB to D4
  • Button to D3

Step 3: RTC Modules "LowPower" Modifications (optional)

In DS1307 cut 2 traces, remove R6 and make solder joint

In DS3231 cut 2 traces

Step 4: Firmware

Arduino sketch:

https://github.com/cbm80amiga/N5110_DHT11_logger_G...

N5110 library:

https://github.com/cbm80amiga/N5110_SPI

Configuration options:

#define USE_DS3231 -> to use DS3231 instead of DS1307

#define REG_IN_RTCRAM -> registers are stored in RTC RAM (only for DS1307)

Sensors Contest

Participated in the
Sensors Contest

2 People Made This Project!

Recommendations

  • Make It Bridge

    Make It Bridge
  • Big and Small Contest

    Big and Small Contest
  • For the Home Contest

    For the Home Contest

14 Comments

0
JGW
JGW

Question 6 months ago on Step 4

I have spent several hours trying to get this project to work, all connections have been scrutinised many times and although the firmware uploads with no problems nothing is appearing on the LCD, I have proved all hardware is OK using other firmware projects so am confident that the problem is not the hardware , what am I doing wrong. thank you in advance.
JGW

0
fritsbeiler
fritsbeiler

Question 1 year ago on Step 4

Best,
I would very much like to build the datalogger but I run into error problems when compiling and unfortunately this bit of programming work is beyond my knowledge. I have searched the internet and have already tested a lot with offered solutions but I cannot get it compiled "correctly" and you may have the solution. Sincerely,
FB.
exit status 1
'lcd' was not declared in this scope >>>>lcd.clrScr();


0
Stringdingetje
Stringdingetje

Question 1 year ago

Hi, just tried to repeat this wonderful experiment with IDE 1.6.5, but it says "sketch too big".
It seems 2kb too big, but I use the same components (ds3231 option), any idea what might fix this issue?

0
lodosi
lodosi

Question 2 years ago

I try to make this project by using:
Arduino pro mini 3.3v, 8Mhz
HX1230 lcd
DHT22 humidity sensor
DS3231SN rtc
Rotary encoder

I use your HX1230_SPI and/or HX1230_FB libraries, instead of N5110_SPI.h
All example sketches of hx1230 libraries run on my lcd without problems, but N5110_DHT11_logger_GUI.ino does not. I only get a faint black screen with nothing moving.

Is it possible to run above hardware by using your N5110_DHT11_logger_GUI.ino (suitably modified, so that some menu items are not included to make place for storage), if yes how?

my modified sketch:

#define DHT11_PIN 14
#define BACKLIGHT 7

#include
#include
#include
#include "HX1230_FB.h"
#include

#if USESPI==1
#include
#endif

// *** CONNECTIONS ***
#define LCD_RST 9
#define LCD_CS 10
#define LCD_BL 7
#define LCD_DIN 11
#define LCD_CLK 13

HX1230_SPI lcd(9,10,11,13);

#include "c64enh_font.h"
#include "times_dig_16x24_font.h"
#include "term9x14_font.h"
#include "tinydig3x7sq_font.h"
#include "small4x7_font.h"
#include "small5x7_font.h"

#include

20210309_174203.jpg20210309_180026.jpg
0
elektrax
elektrax

2 years ago

very nice, i like the menu, good idea using the memory of rtc module

0
danielbeig
danielbeig

Question 3 years ago on Step 4

Hola. El proyecto es muy bueno. ¡¡Te felicito!!
Estoy empezando en el mundo arduino.
Consulta, recibo este error: 'escribir' no se declaró en este ámbito
En esta línea de programa: escriba RTCMem (REG_LOGINT, logInterval);
Porque puede ser?
¡¡Muchas gracias!!
danielbeig@hotmail.com

0
MichelH13
MichelH13

3 years ago

Hello
I am impressed by this program.
Possibility to change the screen: st7920 instead.
email: hohm.michel@free.fr
thanks in advance.

0
cbm80amiga
cbm80amiga

Reply 3 years ago

Unfortunately ST7920 draws more current and is not good candidate for low-power projects. And because of frame buffer memory organization it is not easy to port current software to this display.

0
Dareius
Dareius

3 years ago

Hi,
I followed your project and everything is working fine. I am thinking that, by using the DS3231, it could be possible to use alarms (by using pin D2), settable with rotary encoder, and most importantly an external EEPROM with increased size. I know how to set alarms by using DS3231, but how can be changed your code to achieve this? I am trying to understand your code, but I am a newbie

0
cbm80amiga
cbm80amiga

Reply 3 years ago

For more new functions you would need to remove some code and current functionality because almost all ATmega flash is used. Regarding external EEPROM you can simply add it to the circuit, make sure you use correct I2C address or change it if it conflicts with RTC EEPROM.

0
Alex in NZ
Alex in NZ

3 years ago

Nice use of resources. Thank you for sharing your work. Thank you also for writing that 5110 library. The one I was using was really resource hungry, so I'm looking forward to experimenting with yours :-)

0
cbm80amiga
cbm80amiga

Reply 3 years ago

Thanks. My library saves as much RAM as possible and renders everything directly in N5110 frame buffer. But if you need some pixel graphics it is still possible to use smaler frame and copy it to LCD like in my above project.

0
moonguru
moonguru

3 years ago on Step 4

In the DS3231 all I do is remove the 200 ohm resistor in the charging circuit. This will prevent charging a non rechargeable battery and avoid any danger.

0
cbm80amiga
cbm80amiga

Reply 3 years ago

I remove power LED too, to save some energy.