I have tried to connect Arduino Uno to Python code on Colaboratory, to send information to the Arduino using Pysireal library, but I didn't success, I kept reserve this Error on Colab:
" SerialException: [Errno 2] could not open port COM5: [Errno 2] No such file or directory: 'COM5' "
I'm sure that this port is connected, but Colab can't find the port because it’s on local environment.
What can I do to solve this Error ?? is there any way that can I connect my Arduino to Google Colab ?
Hakam Salti.
Thanks.
The Colab instance is connected to computer on the Google cloud (unless you've set up a local instance): the code doesn't execute on your machine, your typing code into a web interface that remotely runs that code, returns the result and it gets displayed back on that interface.
The Arduino is connected to your computer (a PC by the looks of the serial port).
Your question doesn't specify which way the data goes: send Arduino data to Colab, send Colab data to Arduino or bidirectional.
If you had a WIFI connected microcontroller, you could push the data online through an API, like Firebase
For USB, you'd need this sort of connection:
Arduino (OS/serial driver) <-> Browser <-> Colab
To connect the Arduino to the browser you'd need to use WebSerial or an app that has serial access that can also act as a web server (such as a WebSocket server). Since you're using Python for colab you can write a script on your PC that uses pyserial and a websocket server such as Tornado, Flask, etc. (p5.js does something like this with electron in JS and they have prebuilt apps)
The second part is getting that data which is now available to your browser, but locally, available to the Colab notebook. There are multiple ways of doing this, but this WebCam example looks like a good starting point.
Another variant of this might be:
Write a local script that acts as basic web server (http/websocket) and can access the serial port
make that local web server acessible from the internet (ngrok can help here)
access that websocket version from python (via a websocket client or http client pip package)
Update I've posted a couple of options using p5.serialport here.
For reference here are a couple of tested options using the afore mentioned p5.serial (and it's p5.serialcontrol utility):
Option 1: use Jupyter's HTML feature to run client side code (p5.serial) connecting to the p5.serialcontrol utility on your computer:
from google.colab import files
from IPython.display import HTML, Audio
from google.colab.output import eval_js
from base64 import b64decode
C_HTML = """
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.min.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.jsdelivr.net/npm/p5.serialserver#0.0.29/lib/p5.serialport.js" onload="setupSerial();" onerror="console.warn(e)";></script>
<script>
const serialPort = 'COM13';
let serial;
let isOn = false;
function setupSerial(){
serial = new p5.SerialPort();
serial.open(serialPort);
setInterval(blink, 1000);
console.log("serial setup complete");
}
function blink(){
isOn = !isOn;
if(serial){
serial.write(isOn ? '1' : '0');
}
}
serialInterval = setInterval(checkSerial,500);
function checkSerial(){
console.log('p5.SerialPort',p5.SerialPort);
if(p5.SerialPort){
clearInterval(serialInterval);
setupSerial();
}
}
</script>
"""
def run():
display(HTML(C_HTML))
run()
Option 2: use a reverse tunnel (ngrok) to have the Python side connect to p5.serialcontrol via WebSockets (though you'd need to compose the messages p5.serialcontrol expects maually):
run p5.serialcontrol
run ngrok tcp 8081 from Terminal/Command Prompt (note you may need to setup a free to use auth token for TCP)
install webocket-client on Colab and connect to the websocket (note as opposed to using the p5.serial library in JS, you'd manually put together the messaages to send to p5.serialcontrol's websocket server (e.g. '{"method":"openserial","data":{"serialport":"COM13","serialoptions":{}}}' to open the serial port, '{"method":"write","data":"1"}' to write '1' to serial, etc.))
To install websocket-client in colab you'd use:
!pip install -q websocket-client
and here's an example that turns on LED on for 1 second then off (using the above Arduino example):
from time import sleep
import websocket
# when the websocket is open send a serial open command (on port COM13) then send a '1' then a '0' with 1 second in between
def on_open(ws):
ws.send('{"method":"openserial","data":{"serialport":"COM13","serialoptions":{}}}')
sleep(1)
print('sending ON')
wsapp.send('{"method":"write","data":"1"}')
sleep(1)
print('sending OFF')
wsapp.send('{"method":"write","data":"0"}')
def on_message(ws, message):
print(message)
def on_error(wsapp, err):
print("Got a an error: ", err)
wsapp = websocket.WebSocketApp("ws://YOUR_NGROK_TCP_SERVER_HERE",
# YOUR_NGROK_TCP_SERVER_HERE example #.tcp.ngrok.io:#####,
on_message = on_message,
on_error=on_error)
wsapp.on_open = on_open
wsapp.run_forever()
(also note run_forever() is a blocking loop: based on your application you may want to manually run open and control a websocket connection (as opposed to using WebSocketApp) or use threading, depending on what makes)
An instance of a BizTalk send pipeline has started to run continuously. On 09/12/2021 an attempt was made to send a file via SFTP, which retried several times but ultimately failed due to a network issue. The error from the event logs is:
The adapter failed to transmit message going to send port "Deliver Outgoing - SFTP" with URL "sftp://xxx.xxxxxx.co.nz:22/To_****/%SourceFileName%". It will be retransmitted after the retry interval specified for this Send Port. Details:"WinSCP.SessionRemoteException: Network error: Software caused connection abort.
For some reason BizTalk made another send attempt at 1:49pm on 10/12/2021 which succeeded as confirmed by the administrator of the SFTP site. Despite this, BizTalk continued making intermittent send attempts and the pipeline instance is still running. The same file has been sent 4 times to the SFTP server.
The pipeline instance in theory should have suspended at 9:47pm on 09/12/2021. I have been able to confirm definitively whether anybody resumed it, but it seems unlikely at this stage. In any case, after sending successfully the pipeline instance should have terminated and should not be re-executing intermittently.
Does anybody know what could account for this behaviour? This is occurring on BTS2020 with CU2 applied.
I've sent messages over SFTP where the WinSCP interpretation of the date-modified attribute doesn't work with a specific type of SFTP server.
With the WinSCP GUI a dialogue box appears and you can disregard this error, but this option isn't available with BizTalk's GUI. This error appears when a file with the same filename already exists on the server and is supposed to be overwritten.
My solution was to create a pipeline component that removed %SourceFileName% on the server. The pipeline component (just like WinSCP GUI) can disregard the modified-date.
While connecting SFTP I am getting following error.
com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
Please guide me,
Actually i think the answer is trivial. You are not able to open a stream i.e. the sftp connexion is not estabmlished sucessfully. Check wit IT team or support if there is firewalls or so and that can see you arriving on the server.
I am very new to aws IOT. I am getting the error:
iot_tls_connect L#143 TCP Connection Error.
I am trying to use the sample aws c code. I have replaced the header config with the config for my account. but none of the sample example go beyond this error. I am using Raspberry Pi.
Sounds like you have the correct certs/keys in place. Make sure the host name is just .iot.us-west-2.amazonaws.com and not https://A<...>.iot.us-west-2.amazonaws.com if you copy-paste it from the console.
I am a bit confused about how to use socket.io with Meteor. There is a package called socket-io-client. Is that the only package that I should use or socket-io is required for the client side?
Have anyone implemented a connection? I have managed to print out on the terminal a message that indicates that there is a connection on the server but I cannot print any output on the browser console. Instead I get a message about encoding Uncaught TypeError: response.setEncoding is not a function.
Does the connection is on the same port as my meteor server or must be running on different port?
Thanks very much.