Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Running the LDR example code

We are about to run two programs:

  • chapter09/ldr_ads1115_calibrate.py, which will help us calibrate our LDR readings
  • chapter09/ldr_ads1115.py, which monitors the light level and switches on the LED when the light falls below a configurable level

First, we should check that the ADS1115 is connected correctly and can be seen by your Raspberry Pi. Run the i2cdetect command in a Terminal. If your output does not include a number (for example 48), then please verify your wiring:

$ i2cdetect -y 1
# ... truncated ...
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# ... truncated ...
We first covered the ADS1115 analog-to-digital converter and the i2cdetect utility in Chapter 5, Connecting Your Raspberry Pi to the Physical World.

Let's run the examples, starting with the calibration program:

  1. Run the code found in the chapter09/ldr_ads1115_calibrate...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461