1-Wire Temperature Sensor

EOS 5D Mark III-101-2022

1. Temperature Sensors For my Home Automation project, I require a temperature sensor for my room controller units.  I tried a couple like NTC’s and an analog sensor (MPC9701A), but none of these gave me satisfactory results.  Especially the drift in these sensor was quite high and as a consequence the precision pretty worthless for room temperature; in the best case I had a precision of ±2°C. After some research, I came up with a … Continue reading

Home Automation – Room controller

I started designing the room controller for my home automation system.  Each controller will contain: 2.8″ TFT with touch panel SD card reader PIR sensor POE ethernet power regulator controller board The controller should fit in a double regular light switch (built-in European version).  I started with the front plate and ordered the required components below:   A small preview of what the LCD might show:  

SD Card C driver – Poor man’s FAT

SDI Card Reader SPI

To get my SD card driver going, I’m simply dumping files on it with a regular computer.  The SD card is formatted with FAT16.  This is very useful if you need to edit the files first on a PC; as you use the SD card with an ordinary card reader, your PC will see the card as a regular disk drive. To get the data at the micro controller’s side, the operation is a bit … Continue reading

SD Card C driver – Read multiple sectors

SDI Card Reader SPI

In a previous post I showed you how to read a single sector from a SD card.  Now we’ll progress a little further by reading multiple sectors at once.  Since on a micro controller this very memory consuming, such an operation can only take place when the data is transferred immediately to its destination without using large buffers.  In my example I’m reading data across multiple sectors from an image file on the SD card and … Continue reading

SDCC for PIC with MPLAB X

Before This week I’ve been fighting with my PIC18F4550 for my TFT LCD abd SD card reader controllers.  I’ve been using the HiTech C before and since a couple of months XC8 from Microchip, but now I encountered some very strange behavior.  The timing of the SD card access was not right according my logic sniffer, thus I started to dig deeper for the cause.  I figured it out quite quickly (the XC8 compilers warns … Continue reading

SD Card C driver – Read a sector

SDI Card Reader SPI

Initializing the card was the difficult part, now the fun can start.  Once the SD card has been initialized successfully (see this post), the clock speed can be increased to whatever speed your card can handle.  I’m using the SPI’s maximum speed according to the installed crystal and PLL.  This gives me a SPI clock frequency of 12 MHz, well within the range of what most modern SD cards can handle. Once the read sector … Continue reading

SD Card C driver – SD Initialization

SDI Card Reader SPI

1. Power Up During the initialization phase, the SPI clock must be lowered to 400 kHz according to the standards.  However my PIC is unable to lower to that speed,  the lowest I can get with CPU clock of 48 MHz is 750 kHz (Fosc/64).  Tests have proven that, with the cheap Chinese SD cards I use, this higher clock speed is not a problem.  I tested a couple other cards and I couldn’t find … Continue reading

SD Card via SPI – C driver

SDI Card Reader SPI

Together with my TFT LCD screen came also a SD card reader.  The card reader is very useful to extend the microcontroller’s limited memory.  When using LCDs, the memory (ROM) of your controller quickly gets eaten up by the fonts and bitmap images that consume quite some memory.  A typical font takes up about 4 KBytes, a bitmap image for 320×240 pixels takes 133 KBytes (262000 colors).  I’m working mainly with PIC16F and PIC18F series microcontrollers which limits … Continue reading

2.8″ TFT LCD

EOS 5D Mark III-101-1743

I recently bought a 2.8″ TFT LCD screen with touch panel and SD card reader for 10€ on AliExpress.  The LCD is driven by an ILI9325 chip (serial, 8-bit, 16-bit or 18-bit interface). The touch panel is controlled by an ADS7843.  The SD card reader is accessible over a classic serial interface. I have two applications for this little screen: controlling my model railroad and build my custom made domotic system. The idea is to … Continue reading