I am doing a pet feeder with React-Native app - Node.js server - Arduino (ESP32) but I can't figure it out how to make it work so it drops food at specific times.
I was looking into nodeJS libraries like node-schedule or cron but I can't figure it out or they don't seem to fit my needs.
At this moment I can make it drop food when I press a button in my app, but that would make it too simple (I want both manual AND automatized tasks).
My intention is to schedule feeding hours for your pet to eat, for example at 9:00, at 15:00 and at 21:00 via app, with some sort of alarms, while also being able to check them on demand and edit/delete options.
Any ideas on how could I do it, please?
You don't necessarily have to trigger the "drop food" command from the node app. I've written firmware for a device that connects to wifi, updates its internal date/time from a NTP server, then wakes up at a specified time every data to connect to a server and get setting updates. Ours is a battery powered device, so it doesn't just stay connected to the server all the time, and I used the ESP-IDF but the code was simple enough. I did some research and you can do the same process with an ESP32 using the Arduino Core.
Basic Idea
You could:
Set the times you want the feeding to occur in the app, which then sends those times to the device through BLE or your node app and store them in Flash
Calculate the number of milliseconds until the next feeding
Set a FreeRTOS timer to interrupt after that number of milliseconds to trigger a feeding event
Then after a feeding event occurs:
Check Flash for the next feeding event
Calculate the number of milliseconds
Set a FreeRTOS timer to interrupt and trigger a feeding event
Repeat
Resources:
Setting Local Time on Arduino using NTP
Using FreeRTOS timer interrupts on Arduino
Related
I am able to use bleak and get data from all 5 BLE sensors. But the problem is that I am unable to identify which data is from which device. I mean i need a string representing the address of the device alongwith the data itself.
I was able to get data simultaneously from all the BLE modules using bleak in Windows, as well as on raspberry pi.
The only problem with Windows is that if you use Bluetooth 4.2 adapter & above. It will be much better for the high speed data rate, and proper devices connection handling. As with the 4.0 adapter, I have always gone through one or two exceptions each time i started the script, and the maximum number of connections I got was 3.
When i tried this script on Raspberry pi 3b+, it has on-board chip of Bluetooth 4.2. It was able to give high speed data rate, and my 5 sensors were connected to it simultaneously.
Also, The two_devices examples in bleak source code on Github, is very good example for starting with further coding.
And if you run the script and found the data on console, but you were unable to get that which data is from device. Then you need to use functools, (what it does is it will inject the client you're connected to at present, with the callback function, and it will make the work much easier).
Check this out on Github: https://github.com/hbldh/bleak/issues/601
I am trying to evaluate the suitability of some different wireless interfaces for our project on 2xRaspberry Pi 4 and currently I’m evaluating Bluetooth Low Energy. Therefore I have written an Central and Peripheral device application with the Qt framework (5.15). In my case the latency time between messages is important, because of some security aspects. The message size of each command is around 80-100 Bytes. In one of my tests I have sent 80 Bytes commands every 80ms. Ideally the messages should be received on the other device in 80ms interval as well. For the LAN (TCP) interface this test works well.
For Bluetooth Low Energy I observed that messages, which are sent from Peripheral to Central work quite good and I measured no big delay. Different results I got for the Central to Peripheral direction. Here, I have received the messages in the interval of 100ms to 150ms really exactly. It seems that there couldn’t be a very big magic behind it, so is there any plausible explanation for this? I tested it with a Python script as well and I observed the same results. So it seems that the Qt implementation shouldn’t be the problem.
During research I found out, that the connection interval may influence this, but in Qt the QLowEnergyConnectionParameterRequest (QLowEnergyConnectionParameters Class | Qt Bluetooth 5.15.4) doesn’t work for me. Is there any command, where I can set the connection interval for test purposes at the command line on Linux?
Kind regards,
BenFR
It is possible that your code is slower from central to peripheral because WRITE is used instead of WRITE WITHOUT RESPONSE. The difference is that WRITE waits for an acknowledgement, therefore slowing the communication down, while WRITE WITHOUT RESPONSE is very much like how notifications/indications work in that there's no ACK at the ATT layer. You can change this by changing the write mode of your application and ensuring that the peripheral's characteristic supports WriteNoResponse.
Regarding changing the connection interval, the change needs to be accepted from the remote side in order for it to take effect. In other words, if you are requesting the connection parameter change from the peripheral, then the central needs to have code to receive this connection parameter change request and accept it.
Have a look at the links below for more information:-
How does BLE parameter negotiation work
Understand BLE connection intervals and events
The different types of BLE write
With the update of iOS 7.1 there is much changes in the ibeacon API for requesting, ranging beacon in the background even when app is killed or not launched, here are some of the things i observed as per the ranging for the beacons , in iPod 5th gen running with iOS 7.1
didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
doen't get called, but where as i run the same code in iPhone5 with 7.1 all the methods were getting called, its kind of a weird behaviour i'm facing,
http://www.proxima.io/blog/posts/2014-03-12-ios-7-1-ibeacon-tech-deep-dive/
as per the above link , it gives me something like there is not much update about ibeacon for the iOS7.1 in iPod 5th generation
Does any one faced this kind of same issue?
Be sure you wait up to 15 minutes to get a call to didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region before you conclude it does not work. On some devices, detection cash take that long. See here. Do not expect calls to be received on both devices in a similar time frame. One may be fast and the other slow based on model and internal state.
Other tips: try rebooting both devices to put them in the same state, and verify the problem persists. Avoid running other iBeacon or Bluetooth apps simultaneously, as this can affect your test results. I do not have access to an iPod for testing, but I know other folks report (including those at the page you reference) that iPods work fine with these APIs
I have the following Setup:
A Centos machine with asterisk running that is connected to a Router via Ethernet. The Router answers the calls from my asterisk console and is itself again connected to my Centos machine via analogue RJ11 cable and a Digium PCI Card. (all for testing purposes of the router and running fine)
So I call and pick up the call at the same machine.
How can I now measure the delay between the audio of both channels?
I already tried to use the Monitor() function and evaluate delay signal based with cross correlation, but it seems like the Monitor function is not an accurate tool for recording at a precise time. (It doesn't start recording when I start the Playback() of my testfile)
Is there another possibility to get the delay between caller and callee?
Thanks
You can use Echo application on one end and send Beep on other end.
After that you can measure delay between beeps.
There are no any app which do such measure, but you can ask some developer do it for you.
I wish to know how to generate local notification alerts similar to apple's clock alarm (that comes with the iPhone) while my application is the the background and/or the iPhone is closed. Currently I gets a single vibration and a single play of my ringtone. This is not sufficient and must run in loop till having user response. So how the did it in Apple? TNX.
They used private APIs that are not accessible to normal developers like you and I. The best you're going to get is that one ring and one vibration, unless you're not going for distribution in the App Store.