I used to use esp8266 with its deep sleep options to wake up with timer and to wakeup with disabled RF like this
ESP.deepSleep(TimeInMicro, WAKE_NO_RFCAL);
However now I am using esp32. I found how to wake it up with timer but I could not find an option to wakeup with disabled RF.
my question is this option possible in esp32 and how to implement that?
Thanks
From the docs: http://esp-idf.readthedocs.io/en/latest/api-reference/system/sleep_modes.html
WiFi/BT and sleep modes
In deep sleep mode, wireless peripherals are powered down. Before
entering sleep mode, applications must
disable WiFi and BT using appropriate calls ( esp_bluedroid_disable,
esp_bt_controller_disable, esp_wifi_stop).
WiFi can coexist with light sleep mode, allowing the chip to go into
light sleep mode when there is no network activity, and waking up the
chip from light sleep mode when required. However APIs described in
this section can not be used for that purpose. esp_light_sleep_start
forces the chip to enter light sleep mode, regardless of whether WiFi
is active or not. Automatic entry into light sleep mode, coordinated
with WiFi driver, will be supported using a separate set of APIs.
There's a list of all the parameters you can configure with esp_deep_sleep_pd_config prior to entering deep sleep, along with rich information about lots of other deep sleep topics.
For example you can do this sort of thing, exercising a fine degree of control over how your device deep sleeps:
esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
esp_deep_sleep_enable_timer_wakeup(((uint64_t) sec) * 60);
esp_deep_sleep_start();
Related
I have looked at some posts within this domain (e.g. iOS background fetch custom interval) and I am concluding that what I need to do is not possible.
I have an external device communicating to ios over bluetooth (NFC chip card reader). The external device goes to sleep if not pinged every minute (59 seconds).
When the app is in the foreground I can manage the pinging. When in the background I want to continue to ping. Is this impossible?
The ping operation is fast; it is just to send a message and I dont need a response back to ios.
(What works really well is the opposite, bluetooth communication can flow from the device to ios from the background. That is done via UIBackgroundModes in Info.plist to bluetooth-peripheral.)
Please note that I am feeding the iphone from external power in the application here. It is an industrial application; and the normal iphone usecase is not applicable.
Short answer, no. The best iOS offers is back ground fetch. But there is no guarantee when background delegate method is called. You can specify a timespan as a guide but it primarily based on how often the app is accessed.
https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started
I need to publish state of a switch (1/0) to an MQTT broker. I am planning to put it to deepsleep since this is a battery operated application. Is there a way to awake ESP8266 from deepsleep using external interrupts?
When the state of the switch changes, ESP awakes and transmits switch state to MQTT broker. After that it again goes to deepsleep.
I found no information about external interrupts in ESP. As I got to know, only clock is ON during deepsleep and not sure whether my goal is feasible. If not, I would be glad if you can please suggest an alternative for this (using ESP).
Lakmal
Sure, see the discussion here, basically if CH_DP goes high the chip wakes up.
You can also try my solution here. I use one transistor to enable interrupt to reset after ESP wakeup from deepsleep.
I am using Multipeer Connectivity Framework in my APP and its working absolutely fine but when APP is invoking any API or downloading any file from server then its delaying the response. Sometimes its failed and sometimes I am getting Time out error.
I have also checked "Network" status on xCode debug navigator and found that speed is going up and down instantly and never going beyond 6kb/s and sometimes its showing as 0 kb/s but when I disable Multipeer Connectivity then it works fine and speed going at 70kb/s too.
I have also noticed that if bluetooth is ON then its happening not with the Wifi.
Any suggestion would be really appreciable.
This is happening because when advertising, Multipeer always advertises on the wifi (there's no way to say bluetooth only). The way it advertises is by switching the wifi access mode into adhoc multiple times per second to find other peers, then switching back to AP mode (ie. resuming its connection to your wifi router). Doing this is highly disruptive to large transfers.
You have two options to fix this:
1) as soon as you can, after getting connected, call stopAdvertising(). This will stop the wifi mode from being constantly changed, and your throughput will resume at its normal rate. Warning: you cannot micro-manage this, because it takes up to 30 seconds after calling stopAdvertising() until it takes effect
2) switch from Multipeer to an alternative framework that allows you to specify bluetooth-only, and only use bluetooth. I wrote one called BluePeer which I use in my apps. It is unicast (not multicast) and supports roles like Client/Server (as well as role-less like Multipeer)
I am building an assistive iOS app for a kid that uses a switch to control his computer (a simple button that can send only one massege to the computer).
I am looking for a way to connect my app to a switch that can send click events to my app.
It can through by BT, IR or even through the earphone connection (headset port).
(BTW he can not use the iOS screen as the switch).
Any ideas ?
A BT connection requires you to be a certified MFi developer, and that requires money and a real company.
The headphone port would be a great place to interface with. You could wire a simple switch over the microphone line and ground line which, I think, would create a square wave duty cycle for on and off. I've done something similar where we used the headphone port to communicate to a microcontroller through a sound wave that was then converted to 16 bit packets and used to control additional hardware and also give feedback from that hardware.
Another option is a wifi connection, an arduino with a wifi shield and the button on that.
Edit:
The more I think about it, the more I would say use the headphone port. It will be super cheap, the programming to detect the presses will be really easy, and this will probably be the fastest way to achieve your solution. Provided you can solder.
I'm going to suggest going down a different path. Instead of trying to connect the switch directly to the iPhone, use something like an Arduino board with both physical switch and ethernet I/O ports plugged into the local network, and create what amounts to a physical I/O server.
The Arduino handles the physical interfacing and your iPhone app only has to handle the communications protocol to the Arduino over Wi-Fi.
One inexpensive solution would be to use the mic or mic input on the headset port. Connect the switch up to some sort of tone generator (555 timer or Arduino, plus piezo speaker or headset cable). Have the app run an input Audio Queue, and pass the Audio Queue input buffers to a DSP narrow band filter or an FFT. Monitor the frequency band of the tone generator for any significant energy burst above the background noise level. Potentially use multiple separate tone frequencies for more than one switch.
Added: Another simple alternative might be to use the switch to activate a solenoid or small motor (scavenged from an old motorized toy or similar) to tap a capacitive pen or ball of conductive foam on the iPod Touch display. No MFi, WIFI or audio DSP coding required.
For a GPS tracking app, recording location signals with WIFI turned on results in really imprecise data or data with gaps.
I've used the Reachability queries to detect if wifi is available prior to starting tracking. The problem is that if when that query is made the wifi is enabled but not connected to a network, it shows that the internet is not reachable via wifi, but that's not an indication of if the setting is disabled in the settings app. This means that if the user starts running and a connection is made mid-run, they'll get a location signal from the wifi instead of the GPS or cell network. Consequently the accuracy on those data points can be > 10 meters so I want to skip that point. The issue is that on wifi they'll have a large blank period where their signal wasn't recorded.
So how can I check if wifi is enabled but disconnected?
I've read all the other reachability discussions I could find but this seems to be the one gap with lots of responses incorrectly suggesting that reachability solves this out of the box.
...and I'm not going to require wifi - just alert them to the fact that it is enabled so at some point in their workout their location data might be lost (due to inaccuracy).
It's been quite a while since you asked, but I just came across this one.
It doesn't look like there is any way to do it if you want to obey Apple's rules. sysctl and ioctl won't work because there are no flags which will show you wether WiFi is enabled. For example the flags for "UP" and "RUNNING" will be the same if WiFi is disabled or WiFi is enabled but not connected.
Apple's own WiFi framework uses mach to directly communicate with the kernel and I doubt Apple would allows such code in the AppStore.
This IS possible, but the solution is obscure and ugly. The short answer is that if you see TWO interfaces with the name "awdl0" then WiFi is enabled, just one and it's disabled.
See Better way to detect WiFi enabled/disabled on iOS? for a more complete description and sample code.