SOCIALS 

SUBSCRIBE 

 Please subscribe.   So, you will get notification of the latest exciting posts. 

© 2023 by FEEDs & GRIDs. Proudly created with Wix.com

ABOUT FEEDs & GRIDs

My name is Mike.   This blog is made especially for you to enter my technology universe.  You will find new ideas and skills that may be helpful to you.   Feel free to leave your comments.   I am excited to hear from you.  Thank you. 

I2C Tutorial for Renesas S5D9 board: Add an External SHT31 sensor. (Part2)

December 14, 2017

 
Project Goals
  • Take what is developed from Part 1.   

  • Add an external SHT31 sensor. (new hardware) 

  • Change the code to read the current temperature (F) from an external SHT31 sensor instead of an onboard AMS EN210 sensor. (software change)

  • Add the code to interface with SHT31.  (new software code)

Screen shots

 Board

 

Renesas S5D9 IoT Fast Prototyping Kit

 

Software

 

1. Renesas E2 Studio Tool version 5.4.0.023

2. Renesas SSP version 1.30

3. S5D9 IOT ENABLER pack file

 

 

Hardware

 

(only new device for Part 2)

1. Temperature and Humidity I2C SHT31 Sensor (Seeedstudio)

 

(Part 1)

1. I2c IIC Serial 128x64 Oled LCD Module (Amazon Link)

2. 4 Pin Female Jumper To Grove 4 Pin Conversion Cable (Amazon Link)

3. The Jlink debugger board (included in S3A7 kit)

 

 

Prerequisites

 

1. I2C Tutorial for Renesas S5D9 board: Show The Temperature Reading on an OLED Display (Part 1) 

 

Diagram 1: SHT31 Temperature and Humidity Sensor with I2C Interface.

 

 Demo Video:

Hardware Setup:

 

1. Connect the SHT31 sensor to the same J4 I2C grove header of S5D9 board as the OLED display module.

 

Software Setup:

 

1. No change to configuration.   All the configurations done in part 1 are good for part 2.

 

C code Files:

 

1.  hal_entry.c/h  (Main Program Loop) [Small changes]

2.  i2c.c/h (i2c SSP API calls)

2.  sht31.c/h (subroutines for SHT31 operations) [new]

3.  en210.c/h (subroutines for AMS EN210 operations)

4.  ssd1306_oled.c/h (subroutines for OLED module operations)

 

Note: ssd1306_oled.c/h only contains the code written by Adafruit to access the driver chip ssd1306 on the display module.  The rest of the codes are developed independently.  

 

A number of advantages with this ssd1306_oled.c over Adafruit ssd1306 are:

 

1. It does not require C++ compiler.  It will work with your Synergy C project.

2. It is simpler.   It has all the essential subroutines to draw lines and show letters/numbers/symbols on the display.   So, Adafruit_gfx.library (Graphic library) is no longer required.

3. Supports A-Z,0-9,=,. 

4. It is easy to add your 8x8 pixels font symbols.

 

 

Code Download

 

Note: You can download all the codes from here

 

version 1. (Github_ver1)  - 1st release (only T,E,M,P, =, 0-9, and space are supported)

 

version 2. (Github_ver2) - 2nd release with improvements.  1. A-Z, =, 0-9, period and space are supported.  2. sprintf is supported to simplify the method of writing a message to the display.  

 

        (version 1)

 

        Display "TEMP="
        for (uint8_t i=0; i<5; i++){
             writefontchar(8*i+(HISTXPOS-1), 0, i+1);
        }

     

        (version 2) - A much easier method is used.

 

        sprintf(msg,"TEMPERATURE=%d.",(uint8_t)g_temperatureF);
        writedisplaybuffer(0, 0, msg, strlen(msg));

 

Step by Step Procedure:

 

 

 

Step 1. Open your project (Part 1)

 

Step 2. Open hal_entry.c file.  Add the following lines (Diagram 2a and 2b).

 

Diagram 2a: Add sht31.h include line.

 

 

Diagram 2b: The additional code (Line 97-107) is added to hal_entry.c file.

 

Step 3: Add sht31.h and sht31.c files. 

 Step 4: Build project.

 

Step 5: Run debug to upload the new code.

 

Step 6: If you put your hand over the SHT31 sensor, the temperature reading should increase.

 

Congratulation!   You have completed the tutorial.    Once the I2C configuration is done, you can re-use it for as many new I2C devices you wish to add.  In addition, the I2C communication coding in SHT31.c is very similar to that in SSD1306.c. It makes fast prototyping possible.

 

Challenges!

1.  Add your favorite I2C grove sensor and display the sensor value on the OLED display.

2.  A plot of values over a period of time rather than continuous reading.   Take one measurement every hour and plot a new graph at the end of the day.

 

Tags:

Share on Facebook
Share on Twitter
Please reload

RECENT POSTS

Please reload

FEATURED POSTS

I2C Tutorial for Renesas S5D9 board: Add ThreadX real time OS support. (Part 3)

February 18, 2018

1/5
Please reload

FOLLOW US

  • Grey Facebook Icon
  • Grey Twitter Icon
  • Grey Instagram Icon
  • Grey Google+ Icon
  • Grey Pinterest Icon
This site was designed with the
.com
website builder. Create your website today.
Start Now