Category Archives: Pilogger

The quest of a beacon for cats (part 1)

IMG_6409Mio is a tiny female cat, with a rather independent and proud way of life. She spends quite a lot of time outside doing… well… important cat stuff, among proving her duchess status to the other neighbor cats. However, she never misses us, each evening after work, when we come back home. She can enter the warm house in order to get the well deserved food and attention.

Until one day. And the day after.

It affected me far more than I could expect, but fortunately the worst things I started to imagine were false. Mio came back home. We conclude she might be being locked by mistake in a barn from the neighborhood. That’s where started the idea of a small RF beacon for Mio. It should to be very small, at least a month of battery life, and can enable a kind of search with a receiver.

What exists

I usually enjoy to think about and make solutions by myself, but what exists yet on the market ?

cat_PawTracker

thepawtracker.com

There are some expensive modules that combine GPS and GSM. Usually they come with a subscription (monthly fees) and you get the beacon location from a website. The few days of battery life is problematic, and they cannot be realistically attached to a small cat due to their size.

Some bluetooth tag seems to have some success. They are small and have a long battery life. These tags have however only a 10th of meter range, and some relies on the proximity of a smartphone, with the special app’ installed and running…

balise500pxFinally, over internet I found a very interesting article of someone having the same concern. (https://www.f1nqp.fr/articles.php?lng=fr&pg=144&tconfig=0 in french). I’m less confident with analog RF electronics. In addition, the size of the antenna wire is not very confortable. However this solution should be kept.

Exploring RF modules

I discarded the modules working at wifi frequencies (2.4GHz) for two reason. Maybe I should come back here later, but with a coin-cell battery budget, these frequencies are absorbed easily by walls.

IMG_6406

I made some tests with three different RF modules. From left to right:

1 – A basic 315Mhz transmitter

These modules seems to meet the low power requirements. I can even use a TV usb dongle as SDR to receive and find the beacon. The difficulty comes from the antenna. A 1/4 wave antenna for 315MHz is 23cm long. If I spool the wire inside a small case, it makes a coil and degrades dramatically the antenna impedance/efficiency. So the range goes down to something like 10 meters.

2 – Lora module based on SX1278 at 433MHz

These LoRa modules are amazing. They have a really huge range, more than 500 meters. But the problem is still the antenna at 433Mhz. If I use a simple wire, wrapped in the case, I must increase the output power to the maximum (~+17dBm). Then the battery dies after a day. Mainly because the peak current is up to 100mA, thus not suitable with coin-cells.

3 – ST electronics module base on SPIRIT1 at 868Mhz

The ST SPSGRF module integrates the antenna, in a very small board. The power consumption is very interesting as well, so let’s go a bit further with them.

For each module, made a draft case. I choose a small PIC12F1822 in SOIC package to drive them.

IMG_6407

ST SPIRIT1 tests

The PIC code basically setup the module and send a message every minute. Fortunately, in addition of the numerous application notes, ST provides a little application (STSW-CONNECT9) to generate dthe setup C code of the Spirit1. It is very convenient as the registers are quite numerous. The message sent is just composed of the battery voltage and the battery voltage drop during the RF broadcast.

The 3D drawing is done with Fusion360. To make the case waterproof, I used neoprene glue on the outside join between the cap and the body. With the screwdriver tool that fits the pattern on the cap, there is enough torque to tear the glue appart to unscrew it. I had to pay attention to not cover the antenna with the coin-cell battery. Event shifted like that, I’m sure it reduces the transmission efficiency.

 

 

Receiver and integration

On the receiver side, one interesting feature of the Spirit1 is the RSSI value – in received signal strength. It not gives an absolute distance between the two modules, as it is greatly dependent of the obstacles, but it rather gives an idea.

IMG_6413I used the ESP32 on this side for two reasons. First because there are nice libraries for the RF module and different screens, and because I would like the wifi connectivity. With wifi, I can connect it to my logging station and observe the evolution of the signals. I had a PCD8544 LCD, pretty much enough to display few values and a small history chart. The screen on the receiver let me take it outside and try to locate the signal. It displays RSSI, voltages, and a countdown in order to knows roughly when the beacon will emit.

The PIC code, the ESP32 codes and 3D models are on this github repository: https://github.com/pierre-muth/RF-cat-beacon

 

From the tests I made, the range is around 100 meters. I had the receiver outside in the village, while the cat is (sleeping) in the house (which has half a meter thick walls).

I have now additional logged data channels, I can observe the trends of RSSI and battery voltage on logging station.

 

Conclusion for now

I need to wait more to conclude on the battery lifetime. Over the last 10 days, the voltage seems constant at 3V. I could increase the transmission rate if possible.

I’m not sure about the reception range, is it enough to locate the beacon by walking around in the village? That’s why I should continue to study the other solutions. For example, I just saw it exists 433MHz ceramic antenna as well. Maybe it enables the use of the LoRa module at low power. They are still interesting as their modulation scheme makes the reception very sensitive.

Thanks for reading and take care of your cat.

Advertisements

Wireless remote display

IMG_4370_w

Abstract.

07_rack_frontFor a while now the Pilogger needs a small remote display. The logging station is neither particularly compact nor elegant, therefore I made some tests about a battery powered status display. I tried solutions which I never used mainly by curiosity but also in order to continue to learn something. Especially the Wifi chip ESP8266 and a Sharp memory LCD. For tests logbook, see the Hackaday.io page

Wireless.

esp-12e-frontThe wave of the famous ESP8266 wifi chip from espressif reached me few time ago, but I never experimented it. As a complete image has to be transmitted, the wifi sounds a good solution and the ESP8266 is very capable (beside being very cheap). There is plenty of solution to program it, among the official SDK, microPython or arduino, I chose to test the nodeMCU one. From building the firmware to the integrated development environment ESPlorer, everything is clearly explained on nodeMCU documentation website.

Memory LCD.

LCDA now common solution for very low consumption display is e-ink or e-paper, but another solution from Sharp is interesting as well. There is significant differences between the two, for example the memory LCDs don’t keep the image while out of power. However the current needed to maintain an image is very low, the refresh rate is fast, and the surrounding electronics are very simple. I choose the Sharp LS044Q7DH01, a monochrome 320×240 pixel, 4.4″ display.

Prototype.

For the firsts tests I begun by my usual ugly wiring on a proto-board. I made a schematics with some option regarding the LCD driving. The LCD needs 5V and TI have a convenient boost converter: REG710NA-5. For the ESP12E wiring, Adafruit made a very nice job with their Huzzah board.

Codes.

After some divergeant ideas and solutions, I used sockets to transfert the image from the Raspberry pi to the ESP8266. In fact, the raspberry java code generate directly the data that should be transmitted to the LCD. The ESP Lua code is then just a bridge between socket and the SPI LCD connection. The Lua and Java code is on github (init.lua, socketLCD.lua and WifiDisplay.java).

The ESP is in deep sleep as much as possible. When waking-up, it connects and takes an IP from the house Wifi access point, connects to the raspberry pi socket, receives the image data and sends it in the same time to the LCD, and finally goes back to deep sleep.

PCB.

We cannot stay with a prototype, and for the first time I tried the OSHpark services. What an amazingly good experience! I used Kicad for schematics and board design as the file format is directly compatible. I’ve uploaded one file, and 20 days later the 3 boards were in the mail box. The quality is very impressive, and the pricing for small size is unbeatable. The board can be find here.

1878951471600347659

Frame.

As a frame, for the moment I’m staying with a simple aluminium plate. Few copper plates to fix the board do the job.

IMG_4371IMG_4370

Outlook.

With a 2 minutes refresh rate, the batteries survive around one week. There is then still some improvements to do, such as lower refresh rate during night. Another point I should keep an eye on is the LCD driving. The Sharp datasheet recommend to invert a signal either by a serial command or a physical pin (EXTMODE and EXTCOMIN), thus at a minimum frequency of 1Hz. To lower the consumption, this inversion only appends when refreshing to avoid waking up the ESP8266. After few weeks I didn’t notice any artifact on the LCD. Sharp mention a risk of image retention as well, so an inverted image during night time might be a good idea.

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 !

Wireless temperature probe

Here is an attempt to give some information on the wireless probes I’m using with my Raspberry pi logging station (for the full story). The wireless link is performed by nRF24l01+ modules.

1- Reception

The data reception is done by directly connect a nRF24l01 module on the raspberry pi SPI port. And the pilogger java project  configure and handle the data reception/treatment, thanks to the Pi4J library.

2- The probe

To sense temperature without using long wires, there is a constraint to consider: the wireless module powering. It could be for example from a solar panel, or from a battery. Using a solar panel is not always possible. In case of measuring outside temperature, the solar panel should be deported to the sensor, as the sensor should not be exposed to the sun. Moreover, the charging circuit efficiency is critical for small sized module.

Powering only using battery simplifies the module but requires very low consumption component to last a reasonable time. The nRF24l01 wireless transceiver is very efficient on that way. To keep a very low consumption, I choose the MAX31723 temperature sensor. It is precise and uses the same SPI communication protocole as the nRF24l01 module. To manage these components, I choose the microchip PIC16F1825.

The schematics files of the module below could be find on the github pilogger repository.

wireless_sch

As well as the PIC code in C. The code put the micro-controller in sleep mode for roughly 4 seconds between each temperature measurements and transmissions. And the all circuit is powered directly from two AA Ni-MH batteries. Each components could still work down to the lower battery voltage of roughly 2 volts, and charged batteries are around 2.6 volts which is below the max 3.3 volts of the RF module.

I didn’t yet make printed circuits, then I use prototyping board such as :

In addition of the temperature, I used the internal voltage reference of the PIC to get the battery voltage and send it to the pilogger.

For the moment, I did two of these probes. One is outside in a waterproof case powered by two 1000 mAh AAA  Ni-MH batteries, and  one on the attic, powered by two 2000 mAh AA batteries. I don’t have yet a full battery life-time. I can see the battery voltage decreasing very slowly over a month, but Ni-MH discharging curves are rather flat for low current. I will update this post once probe stopped working !

Edit:

After 100 days of sending 12 bytes of data every 4 seconds, I think we can conclude the overall circuit does not consume too much energy. The two AAA 1000mAh battery voltage only drop by 40 mV. Let see if this can last one year !

out_bat

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…