Raspberry Pi I2C Microchip MCP9800123 Temperature Sensor

Published on Friday 06 July 2012
Categories: Projects | Raspberry Pi | Solar Power |

The plan to use an Android phone and IOIO board to log the solar data has been abandoned after repeated failures of the IOIO boards to run for more than 24 hours without crashing or resetting. It maybe that I have purchased 2 faulty boards, phone issues (on 4 android devices) or some other bug in the code or firmware.

The new plan for the home solar PV and hot water logging system is to use a Raspberry Pi Linux based system and use this with the current sensors to log data both locally onto a mysql database on the Raspberry Pi memory card and also to upload to the online reporting website every minute.

#!/usr/bin/env python3
import quick2wire.i2c as i2c

import time

address = 0x49

with i2c.I2CBus() as bus:
	bus.transaction(i2c.write_bytes(address, 0x01, 0x60))
	bus.transaction(i2c.write_bytes(address, 0x01))
	while True:

		sensora, sensorb = bus.transaction(i2c.write_bytes(address, 0x00),
		i2c.read(address, 2))[0]
		temp = (sensora << 8 | sensorb) / 256.
		print ("%02.02f" % temp)

Raspberry Pi

The Raspberry Pi system image doesnt have I2C support as standard and I needed to install an updated kernel from http://www.bootc.net/projects/raspberry-pi-kernel/ and also GPIO Admin from http://github.com/quick2wire/quick2wire-gpio-admin. I then installed the Quick2wire api libraries from https://github.com/quick2wire/quick2wire-python-api and with help from the developers (http://quick2wire.com/2012/06/i2c-python/) I was able to get one of the MCP98003 temperature sensors to read via a Python script as shown below.

Screenshot of the code running reading a spare sensor.

 Screenshot of the code

The next stage will be to design and build a buffer circuit with a SPI based A/D converter to monitor the analogue inputs from the battery voltage, current sensors and an updated mains current logging system. We are also planning to add additional temperature and humidity sensors outside once we find suitable sensors.



Leave a comment

About Me

Brian Dorey

Welcome to my blog, here you will find my projects and other things.
I make websites and manufacturer and sell expansion boards for the Raspberry Pi range of computers.

AB Electronics Raspberry Pi shop

Social Media

Popular Posts

Small image for Raspberry Pi Zero W external antenna mod

Raspberry Pi Zero W external antenna mod
04 MARCH 2017

Small image for Ford Sync 3 USB Drive Music Playlists

Ford Sync 3 USB Drive Music Playlists
22 OCTOBER 2016

Small image for Echo Dot 3rd Gen Smart speaker Teardown

Echo Dot 3rd Gen Smart speaker Teardown
21 JULY 2019

Small image for DIY Pick and Place V2 Project Complete

DIY Pick and Place V2 Project Complete
23 NOVEMBER 2013