Tag Archives: PIC microchip

Internet Of Mailbox

IMG_20160620_122928b

Abstract.

This post summaries the test I made to produce a mail presence sensor. It is aimed to be wireless, connected to the Pilogger logging station. It is interesting to use a load cell in order to know the weight of the object in the mailbox. But we will discuss the difficulties to implement a reliable solution.

The sensor.

IMG_20160508_174323

Figure 1 – NTC inserted in the load cell

It could be found very cheap load cell on Ebay, with a small board featuring a 24-bits ADC. The ones I used for this test is a 10Kg cell with a HX711 board.

As the principle of sensing is based on the physical deformation of the metallic rod, the system is affected by temperature change. So I decide to use a thermistor (NTC), placed directly within the metallic rod, by placing it in a small drilled hole. (Figure 1, on the left)

The electronic

The HX711 is an interesting chip for its price range. It is design to measure very tiny resistance change using a Winston bridge. It have two channels, one with two gains (64 and 128) and another with a fixe 32 gain. While the first channel is connected to the load cell, the second one is perfectly usable for measuring the thermistor. To do so we have to do another Winston bridge including this thermistor. (Figure 2, on the right)

schematics01

Figure 2 – Wireless mailbox probe schematics

I chose to use the same micro-controller and RF link as the previous wireless temperature probe. In other words, a PIC16F1825 and a nRF24l01+. The difference is the HX711 module and a voltage regulator. The HX711 needs a stable 3.3V, and then I use an analog input of the PIC to have a battery voltage information.

Code.

The micro-controller code is rather simple as well, it sleeps for around 8 seconds, then sequentially get 8 values of HX711 channel ‘A’ and average them, the same for channel ‘B’, then get the ADC value of the battery, and finally send the data with the nRF24l01.

The XC8 C compiler file for the PIC16F1825 is here in Github.

Installation.

I fixed one end of the load cell directly to the mailbox bottom, and the other end to an aluminium plate of approximately the surface of the box. For the tests, I just fixed the proto board on a side with tape, and the battery below.

Tests and data.

The system is surprisingly sensible, a letter is clearly visible on the weight data.

But sensitivity is not precision. And things start to be more complex when I try to figure out how to calibrate the system. There is a link between temperature and weight data, but not only. The entire mechanical system plays a role.

mailbox01b

Figue 8 – One month of data

Figure 8 shows a complete month of temperature and weight data, with arbitrary units (ADC output). While points marked with ‘1’ are the time where a letter was on the plate, the others are interesting. Point ‘3’ shows that a heavy parcel was kindly placed in the box by the postman. But after that, the weight base line did not recover to the same value. Apparently a mechanical bias appeared, it could be a permanent distortion of the load cell.

I could not fully understood the events marked as ‘2’. These drops should reflect a resistance change, so I imagine it could be linked with humidity and water condensation. It seems it disappeared once I cover the HX711 pins and copper tracks with varnish.

I tried to establish a correlation between the temperature values and the weight values in order to compensate the changes. As the event ‘3’ put an offset I have two data groups. I agree the data looks funny, and it is hard to see a true correlation. (Figure 9&10) We could barely see a kind of exponential curve such as Weight = a + b. Temp², but not enough to compensate correctly.

Conclusion.

MB_battery

Figure 11 – Battery discharge in volts

To summarize, the concept is clearly working. I first though the battery would not last so long, but event not fully charged, the 4000mAh li-ion is still alive after a month. (Figure 11).

The HX711 used strait out of the box without shielding gives quite good results. On the 24bit resolution, around 19 to 20 are out of noise, which is remarkable for such a draft system.

As it is, I have at least an idea if there is something present (and roughly how big) in the mailbox, and this everywhere I could have an internet access. To be continued !

Advertisements

The BIG_CLOCK

We need clocks. Once you have passionate activities which absorbs all your attention, if you want to keep contact with the social society surrounding you, it’s crucial to know when we are.

From this observation, it started this project with the wish to use the big LCD panels which take the dust somewhere. They are Lumex LCD-S101D30TR, 7 segment digit 3″ tall. The micro controller is a PIC18F87K90, and it does everything. So the hardware comes down to only a battery, a micro (with surrounding capacitors and an oscillator) and 6 LCD panels.

 

The digits are soldered on prototyping boards, which are screwed to two long rods. A basic white surrounding plastic frame, and I think it does the job!

521631455984494909

No relief now to say “Oh god, I didn’t see the time passing while I’m playing….”

1929151455985127238

For details, go to the hackaday.io project page : https://hackaday.io/project/9687-bigclock

2906641456482643758

 

New sensor: Electrical consumption.

One of the objective I had when I started the Raspberry pi based logging system is to record the power used in the house. My first thought was naturally use a transformer around the main power cable of the house. I tried with this kind of device :

1 – Non-invasive AC Current Sensor

As it give an AC signal proportional to the intensity, it should be use with diode and filtering capacitor to be acquired by an ADC.

As you can imagine, resolution is fixed by the ADC and for low current, you get low precision.

My power provider’s meter is one made in the 60’s, the famous electromagnetical induction watt-hour meter. The metal disc makes a complete revolution every  10Watt/hour or 36KJ. If we divide these 10Watt/hour by the time the disc takes to make a revolution, we get the instantaneous power consumption in Watts.

Principle of rotation detection.

2 – Principle of rotation detection

We now have to detect the passage of short black mark on the side of the disc, and count the time between two. I choose to use a photo-resistor and a red laser diode for high brightness.

I’m using PIC 8bit micro-controllers, and instead of using the ADC, I choose to use the convenient comparator.

A divider made of a potentiometer give the fix voltage to compare with the signal from the photo-resistor. The rotating disc is like a large gear, implies the edge is made of tooth. The resulting signal from the brightness is then not pure square, but more a square with sine on top. Our comparator will see some “bounce” between the two states.

But the dark mark has certain length, brightness drops lasts a certain time. We could imagine then a kind of de-bouncing code (or hysteresis ?) . Consisting of allowing a change of state only if it lasts a certain time.

debouncing

3 – State De-bouncing

IMG_0144

4 – Laser and board installed, yes I should definitively improve this

The absolute precision of the system relies of the watt-meter and the PIC clock precision. Less you consume, more the counted time number increase then more ‘resolution’ we have.

It takes a bit of effort to tune the threshold of the comparator as well as the ‘de-bouncing’ counters. Also, aligning the diode and photo-resistor with the disc behind the small glass window is a bit delicate. To help, three leds indicate the status.

The code of the PIC micro-controller is compiled with Hi-Tech C compiler and is there : link

The logging station is my pilogger project. The RF link is made with a new address of the nRF24L01 network.

It runs now for about a month and have around 1 watt of resolution. I could identify that my fridge consume 90 watts during ~10 min every 90 min. Or that the water circulating pump of my heating system consume roughly constantly 80 watts.

chart_day

5 – 24 hours of power consumption

On the log of this particular 24 hours window, we can see the 3Kw of the traditional oven (I made a cake :oP ), the 1.5Kw of the micro-wave oven, the regular runs of the fridge, some media such as TV plus computer plus audio amp, etc…