MicroPython - is it compatible with gpiozero ?RPi.GPIO? - python

I'm making an IOT project for home automation, including a dozen of Rpi Zero-W using Strech-Lite operating syste, to control and report its Sensor and/ or relay's status.
I believe a ESP32 Ebay link would be much more reliable since it is a controller running code rather that a whole operating system as my current solution ( By the way micro:bit does not qualify since it lacks wifi ).
My question is - can I use gpiozero library ? since my code is based on it

classes supported in MicroPython here

Related

reading any pc compatible racing wheel input

I am an Electrical Engineer student and I am currently doing a Final Year Project on setting up a simulation platform for driving to test my drowsiness detecting device. I am currently looking for methods that can retrieve racing wheel's input data such as steering wheel angle because I need those data to operate my device effectively. I have tried to look up on the internet and I only found these documents:
https://learn.microsoft.com/en-us/uwp/api/windows.gaming.input.racingwheelreading
https://learn.microsoft.com/en-us/windows/uwp/gaming/racing-wheel-and-force-feedback
It seems like windows only support device that is compatible with xbox one or xbox 360 steering wheel. Due to our limiting allowed budget, we could only find some cheap steering wheels that are compatible with PS4/PS3 and PC. Is there any other way that can read input data like steering angle from any pc compatible racing wheel? By the way, I am using windows operating system.
I would really appreciate any help.
Most likely, if your steering wheels are marked as PC compatible, they appear in Windows as joysticks. These devices can be read using the Multimedia Joystick API or DirectInput.
The Multimedia Joystick API docs are here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd757116(v=vs.85).aspx. You use this API by calling a series of C functions, like joyGetPosEx(), which are all available in Windows.h.
DirectInput is more complicated to set up, and works using COM. DirectInput docs are here: https://msdn.microsoft.com/en-us/library/windows/desktop/ee416842(v=vs.85).aspx
XInput is supposed to be the next generation API for input devices, but it only supports input devices that have the layout (joysticks, buttons, etc.) of an Xbox 360 controller.
The documents that you found work with Microsoft's newer "Universal Windows Platform," which is used in the Microsoft store. UWP apps are not able to use DirectInput, and are probably not able to use the old joystick API either.

Python in a webapp (client side)

This is part of some preliminary research and I am having a difficult time figuring out what options might be available or if this is even a situation where a solution even exists.
Essentially we have an existing python based simulation that we would like to make available to people via the web. It can be pretty processor intensive, so while we could just run the sim server side and write a client that connects to it, this would not be ideal.
Writing a UI in Flash/Flex or HTML5, not a problem. However, is there any way to keep the core simulation logic in python without having it live server side? Is there any existing way to embed python modules in either of these technologies?
Thanks all.
Pyjamas: Python->Javascript, set of widgets for use in a browser or a desktop
Skulpt: Python written in Javascript
Emscripten: C/C++ -> LLVM -> Javascript
Empythoned: Based on emscripten and cpython, working on a stdlib? There are bugs to file

Is there a way to "compile" Python code onto an Arduino (Uno)?

I have a robotics type project with an Arduino Uno, and to make a long story short, I am experimenting with some AI algorithms. However, I need to implement some high level matrix algorithms that would be quite simple using NumPy/SciPy, but they are an utter nightmare in C or C++. Even with the libraries out there, this is just getting ridiculous.
Is there any way I can do this project in Python? I think I heard something about the Mega having this capability, but I have an Uno, and replacing it is not an option at this point (that would set the project back quite a bit.) Also, I heard somethings about using Python to communicate to the Arduino via USB, but I cannot have the USB cable in while the thing is running. I need to be able to upload the program and be done with it.
Are there any options out there, or have I just reached a dead end?
There was a talk about using Python with robotics at this years PyConAU called Ah! I see you have the machine that goes 'BING'! by Dr. Graeme Cross.
The only option he recommended for using Python on a microcontroller board was PyMite which I think also goes by the name of Python-On-A-Chip.
It has been ported to a range of boards - specifically he mentions the Arduino Mega which you said is not an option for you, but it is possible it is supported on other Arduino boards.
However, because it is a "batteries not included" version of Python it is more than likely that you will have a real problem getting numpy/scipy etc up and running.
As other posters have suggested, implementing in C might be the path of least resistence.
Update: again, not specifically for Arduino, but pyMCU looks to provide python on a chip. The author states he may look at developing an Arduino version of pyMCU if there is enough interest.
I've started work on a "Little Python" to C++ (called Pyxie - a play on Py CC- Pyc-C) compiler, with the specific aim of compiling a sane subset of python to C++ such that it can run on an arduino.
This is far from complete at time of writing (0.0.16), but it can currently compile a very small subset of python - enough for the arduino "blink" example to run. To support this, it has a compilation profile - which essentially means "compile using the arduino toolchain."
A program it can compile looks like this:
led = 13
pinMode(led, OUTPUT)
while True:
digitalWrite(led, HIGH)
delay(1000)
digitalWrite(led, LOW)
delay(1000)
This parses, performs analysis (like type inference, etc), compiles to C++, which is then compiled to a hex file, which you can load onto your device.
There's a long way to go before it's useful, but it is progressing and does have a roadmap/etc.
PyPI - http://pypi.python.org/pypi/pyxie
Homepage - http://www.sparkslabs.com/pyxie/index.html
In particular a key difference from Micropython (and PyMite) is that it's designed to compile to devices too small to run either implementation. (This also means it's very different from things like ShedSkin which while a Python to C++ compiler target larger execution environments)
It's going to be difficult to get any kind of Python script running directly on the Arduino uno.Reason is that it is an interpreted language, so you will need a interpreter on-board in addition to the plain text script. There is probably not going to be enough memory for all of thatin arduino uno.
What you can do best is to find a way to compile a Python script to native machine code (this is how C/C++ works). I have seen projects around to do something like that for other platforms, but (as far as I know) none which does it successfully for Arduino uno yet.
you can visit http://www.toptechboy.com/using-python-with-arduino-lessons/ for more.
wish this will help you.
thanks!
This is not a direct solution but in your circumstances If I were you, I would write the AI program on my computer and the rest of it in Arduino. after that I would write a flask server with my AI program. and then, port forward from my router to the local machine. finally, make requests from Arduino to the server.

Using python to control a phone with bluetooth

I would like to know if there are any API's for python to programmatically control a phone, like starting and ending calls, but also to record conversations.
I would also like to use the Headphones and Mic of the computer to talk over the phone.
Any info would be great, I tried googling for something, but nothing useful came up.
Be careful when using PyBluez! The results will actually depend on the BT-USB dongle you are using. Depending on the hardware(the BT chip in there), PyBluez will use one or another BT stack - for example there was one from WIDCOMM. Results will vary, as PyBluez is actually wrapping around those stacks - all of which are far from complete.
So, when you have a working project, be sure to know what actual BT stack you were using :)
For Python audio stuff, you could try this.
PyBluez is an effort to create python wrappers around system Bluetooth resources to allow Python developers to easily and quickly create Bluetooth applications.
Unfortunately I've not found a page dedicated to its features, but it could be a good starting point, whether everything you need is in its feature set, or if you could build your application upon it by extending it.
http://code.google.com/p/pybluez/

What alarm/access hardware can I control from *NIX?

Okay, so not strictly a programming question BUT the point is I want to integrate my new building's business access/alarm system into the rest of my *NIX setup at my business. I do NOT want to use some cruddy windows GUI program written for Windows XP SP1 that manages a bare circuit-board via a serial connection and provides absolutely zero APIs. There's got to be something decent out there!
Any decent access/alarm hardware vendors out there? I'd love to interface via python, perl, ruby, etc. to some nice control panel that has an integrated NIC. Heck, I'd even settle for some CLI tool that I could at least exec and parse.
We've got mag card readers on doors/elevators, mag locks, rex's, fingerprint readers, etc. for our access.
We've got standard door/window, motion, etc. for our alarm.
Hardware vendor suggestions?
What is you physical location? If europe you could have a look at EIB-Technologies. Just google for EIB and you'll see many answers for your question. EIB stands for European Installation Bus. It is a technology used for controlling almost everything in buildings (light, alarms, aircon, etc...) using a bus and centralized control centers. Depending on technology providers you'll also have interfaces to *nix systems.
have a look at e.g. link text
Does this answer your question?
What do you actually want to do with your integrated system?
Two of my former employers developed access control systems, both running on Windows. Both provided a programmatic API (DCOM or TCP socket.) *NIX support was another matter, but you avoid the hardware interfacing problem, at least.
One was Honeywell, but that's designed for big systems and will probably be out of your price (and complexity) range. The other (a small startup) doesn't support all of the devices you list.
If your building wiring is RS485, you're unlikely to be allowed to interface over that. Ethernet to the access control software is your best bet.
Ethernet-connected devices have traditionally been uncommon as the configuration is tricky; your typical alarm installer doesn't know about IP addresses, subnets, switches and whatnot.
I suppose the way to go will be DPWS; as Windows provides built-in support for this now, you can expect hardware vendors to jump on the bandwagon.
I ended up finding some good hardware by eData that was run off of embedded Linux with ssh, SOAP, REST, and Web GUI access. Unfortunately the integrator bid way too high and wouldn't commit to working in our time frame, so we ended up with the crappy Kantech stuff. Yay serial cables. :-(

Categories

Resources