Giter VIP home page Giter VIP logo

soft-ata's Introduction

Soft-ata V6.00

In Brief

An Arduino app LIKE Firmata for RPI Pico W running Arduino. Includes a .NET package so that you can write your own client in C# to remotely control Pico devices. Console, Blazor and WebAPI app examples included with MAUI possible later..

Soft-ata rather than firm-ata!


  • Documentation: here

Hot Press

  • V6.81 Blockly Added
    • SoftaWebAPI app now starts with index page
      • Can choose link to BlocklyAutomation or to Swagger
    • 8 simple sample Blockly apps in SoftaWebAPI/Samples folder.
      • Load in Blockly Save Local->Load Blocks and browse to folder.
    • For info see blog post
  • V6.30 Added MeadowLabs-.NET Standard version of app: MeadowLab
    • Note doesn't work: Get "The descriptor is not a socket" error msg.
    • Has been logged with Vendor
    • Meadow labs on GitHub
    • Meadow.Windows desktop version of app works though: MeadowLab.WindowsDesktop with .NET Standard or .NET lib.
  • V6.20 Can send Telemtry pause continue or stop as C2D Msg
    • Eg Telemetry 0 pause 0 to pause.
    • Use Azure IoT Explorer or VS Code etc to send msg to device
    • Also can send raw msg commands eg 240 0 9 0 to pause.
      • 240 = Sensor(Telemetry) 9 = pause 10=continue.
      • Further details, take last/latest post (at bottom) here
    • Can also send raw C2D msg commands to actuator (Servo)
      • eg 242 0 5 0 1 90 to move servo to 90 degress.
      • Need to init servo first though.

About.

The Pico app runs as a TCPIP Service taking commands, running them and returning the result to the client. For setups, displays and actuators, the expected result is simply an acknowledgement "OK:" string. For sensor reads, a data string is returned with an "OK:" prefix. The SoftaLib checks and consumes the acknowledgments data before it is forwarded to the client app.

The RPi Pico W has two procressing cores. Whilst most interactions occur via the first core, some functionality is built into the second core. Firstly, the inbuilt LED flashes under control by the second core. When the Pico app first boots and both cores are ready, it blinks at a slow rate. (4s on/4s off). Once a connection is made, it blinks at 4x this rate. So the client app should try connecting until then. Communication between the two cores is generally from core one to core two and is done in a synchronised manner.

The second core is also used for automous streaming of Sensor Telemetry data over Bluetooth and to an Azure IoT Hub. Once started, it runs with periodic transmissions without futher interaction until a Pause or Stop command is sent. When paused, the transmission continues after reception of a Continue command. For every transmission, there is also a quick double flash by the inbuilt LED.

Whereas Firmata is implemented form the ground up, implemented in terms of protocols with ddevices being added interms of those implementations Softata is implemented in terms of existing spcific Arduino device libaries. To add a device you include its Arduino library and then slot it into the Softata app infrastructure. That code is, in the main, polymorphic. To add for example, a sensor you copy you copy the template sensor.cpp file and implement the methods in it according to the devices library samples. You also create header code for it largely by copying an existing sensor's header. Within the Softata app and SoftataLib code there ar then some specific hooks to add for the device. This process is documented here. This needs some updating.

History

The plan was to implement an Arduino app to run on a RPi Pico W placed in a Grove Shield for Pi Pico. The Pico W has onboard Arduino implemented using the earlephilhowe BSP implementation. The Grove instructure being used because of it's simple standardised connectivity between devices and the shield at both ends. Rather than implement a general purpose interface for devices in One Wire, I2C or SPI, etc, use is made of existing Arduino libraries for Grove devices.

The intention was also to implement a class for each device type (sensor display, actuator etc) such that the class can be extended for each actual device of that type by implementing the base methods. That way, the functionality of the app for a device type needs no modification for any additions. Additional non Grove devices can be added by connecting to a Grove cable.

Ultimately the intention was to stream Telemetry from sensors to an Azure IoT Hub
Communication with a host app using a client service model with the service running on the Arduino app connected to by clients running on a host. This is all now functional.

A .NET library was built that communicates to the service as a mirror of the Arduino functionality. A Console app was built to fully test and demonstrate this functionality. A Blazor app to do same is under development. Similarly a .NET MAUI app is envisaged. Finally, a port of the .NET library to the Wilderness Labs Project Lab V3 device is also envisaged.***

API Documentation

The full API documentation is here (Extended/updated)

Local Docs

Background

I wanted to use a RPI Pico W with Arduino installed controlled by .NET apps. Drilling deeper, I wanted to make the Pico coding available with a Blockly style UI as per CodeCraft. There is also BlocklyDuino.

After some consideration Firmata was considered. But this lacks a simple .NET (not UWP) interface.

Firmata

Firmata is a protocol for communicating with microcontrollers from software on a host computer. The protocol can be implemented in firmware on any microcontroller architecture as well as software on any host computer software package. From

So if there a Firmata app running on a device, a host computrer can interact directly with the device's hardware through a standard protocol over Serial, Ethernet (Wired or WiFi) or Bluetooth. The Firmata protocol can be viewed in the first link below. There are various implementations of it for various devices: ... There is more discussion of Firmata in the Blog post. ...

I could get the ConfigurableFirmata running on a RPi Pico W over WiFi. The.NET client libraries were quite old and used a Serial connection. Using a .NET Tcpip Client, I found that the functionality I could get working with interactively was limited. So I decided to build my own "Firmata", hence Soft-ata.

Soft-ata Projects

  • Softata: The Arduino RPI Pico app
  • SoftataLib: The. NET Library
  • SoftataConsole: A simple .NET Console demo app
  • BlazorSoftata: Blazor Web Server App, some tests as Console app.
  • SoftataWebAPI: Swagger interface to SoftataLib

RPi Pico W Arduino

This requires a setup as per previous repositories here as well as in some blog posts:


Required Arduino Libraries


Usage

See the Console app but the IpAddress as determined when the Pico W runs must match that in the library. The ports must also match. The Console test app has multiple options:

  • 1 Digital
  • 2 Analog
  • 3 PWM
  • 4 Servo
  • 5 Sensors
  • 6 Displays
  • 7 Serial
  • 8 PotLightSoundAnalog
  • 9 UltrasonicRange
  • 10 PotRelay
  • 11 PotServo

The Blazor app has similar functionality.

The SoftataWebAPI is an ASP.NET Core API app presents a Swagger interafce to all of the SoftataLib (.NET) API commands


Roadmap

  • Add more devices: Please submit.
  • Azure IoT C2D commands (Control actuators etc)
  • Please leave suggestions in Issues or Discussions,thx
  • More: See the Blog post (See API Documentation link above)

Enjoy! :)

soft-ata's People

Contributors

djaus2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

soft-ata's Issues

Analog Bug Fix

In V2.40 there was a bug fix where values were read into C# lib from Arduino device but in the Analog class weren't processed properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.