It has been quite some time since I have visited this project. I still have some PCB's in storage that I want to assemble.
I'm not sure what it is about this device but I have had more fun with it than anything else I've made over the past few years.
Today I realized a small PIR sensor has 3 pins just evenly sized and spaced, and with the right pinout to plug into the small header on the top of device that has [Vcc] [PB2] [GND].
My goal was to write a program that would poll the PIR sensor output, and when triggered count how many times it was triggered as long as the device has enough voltage to run. It worked surprisingly well and I forgot how much I love programming in TGRK. It is like a puzzle that needs to be assembled with chopsticks. But when I was developing the device I made some pretty good modifications to my Notepad++ to make programming it a little easier, as well as a Python Serial program that converts all keywords to the numerical program code that the machine reads. I think I may have covered that during development of the device.

About the PIR sensor.
This sensor only puts out a maximum of 3.3v. Which when the Capacitor is fully charged at ~5.2v, it seemed like it wasn't recognizing it. I thought about putting a transistor on it, but as it needs to be high, i would need to use a pnp transistor, and I didn't want to mess with trying to figure that out right now.
Another thought I had was to go into the Tiny Bit Machine Arduino code and add a way to set an interrupt to wake the device from PB2, and allow setting that from inside the TGRK interpreter. Maybe it will happen some day but I wanted to write a TGRK program today.
So my solution was to read the Analog Voltage of PB2, and if it's under 2.6v, consider that a trigger. So far it seems to be working well.
Once the trigger happens, the device deep blinks out the binary number for the count, then sleeps for 5 minutes so as to not count someone moving around a room for 5 minutes.
Another feature I added, just to test some TGRK keywords I had not used until now, was when the program sees the battery is dropping below 2.5v, it will write the total motion counts to an integer in eeprom, then exit the program to a deep sleep.
Testing the device in my room, it seems to trigger nicely from across the room. I will test it for a few days to see how it holds up and how long it will run before it runs out of juice.

Until next time.
Gordon
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.